在Orcle中, 有时我们需要直接给一个数据类型是BLOB的字段插入数据, 但我们只知道BLOB的String。
这时, 我们需要将String转换成BLOB。
可以用方法TO_BLOB(UTL_RAW.CAST_TO_RAW('.............'))
例如:
UPDATE T_SA_EMAIL_TEMPLATES_TX
SET EMAIL_CONTENT= TO_BLOB(UTL_RAW.CAST_TO_RAW('<p>Dear HSP,</p>
<p>You have submitted a medical bill amounting to $100, 000 to MCPS. The bill details are:</p>
<p><strong>Invoice number: %hspBillNo%<br />
Bill Amount: %billAmount%<br />
Submitted by (HSP): %hspCode%<br />
Officer''s ministry: %ministry%<br />
Officer''s department: %department%</strong></p>
<p><strong>Bill Status: %billStatus%<br />
HSP Output Record: %record%<br />
1st Approval remark: %remarks1%<br />
2nd Approval remark: %remarks2%</strong></p>
<p> </p>
<p>If you wish to contact the officer in-charge of approving/rejecting this bill, please kindly use the %contactInfo% link under the General Function to search for the officer''s contact details.</p>
<p>*** This is an automatically generated email, please do not reply ***</p>'))
WHERE EMAIL_TEMPLATES_ID='8';
即使String中有换行, 也可以直接convert。
本文介绍如何在Oracle数据库中将字符串数据转换为BLOB类型并直接更新到BLOB字段中,通过具体示例展示了使用TO_BLOB和UTL_RAW.CAST_TO_RAW函数的方法。

2845

被折叠的 条评论
为什么被折叠?



