在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。