1. 程式人生 > 其它 >oracle插入CLOB型別超過4000個字元報ORA-01704:string literal too long解決方法

oracle插入CLOB型別超過4000個字元報ORA-01704:string literal too long解決方法

技術標籤:資料庫oracle

不建議將超長的欄位儲存資料庫,對於必須要求儲存在資料的場景,分享一個解決方法(基於Mybatis持久層開發);
解決方法:通過宣告變數的方式將資料賦予CLOB變數,通過引用變數進行插入。
Mybatis的XML寫法如下:
DECLARE
   <if test="initData != null and initData != ''">
       INIT_DATA_CLOB_DATA CLOB := #{initData, jdbcType = CLOB};
   </if>
   <if test="finalData != null and finalData != ''"
> FINAL_DATA_CLOB_DATA CLOB := #{finalData, jdbcType = CLOB}; </if> <if test="formContent != null and formContent != ''"> FORM_CONTENT_DATA CLOB := #{formContent, jdbcType = CLOB}; </if> BEGIN UPDATE TTRANSFER_MOBILE_LOG <set> <if
test="initData != null and initData != ''"> INIT_DATA_CLOB = INIT_DATA_CLOB_DATA, </if> <if test="finalData != null and finalData != ''"> FINAL_DATA_CLOB = FINAL_DATA_CLOB_DATA, </if> <if test="formContent != null and formContent != ''"
> FORM_CONTENT = FORM_CONTENT_DATA, </if> </set> WHERE LOG_ID = #{id}; END; 這裡僅提供修改的示例,插入只需要將修改語句改為插入語句即可;