Oracle, convert varchar to BLOB

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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章