Unable to store CLOB data in to CLOB defined column in DB2

浪子不回头ぞ 提交于 2019-12-02 10:34:54

问题


It's a repeated issue i guess, but couldn't find a proper solution yet. Basically I am trying to insert bit huge XML i.e. 32000+ characters in to a CLOB column through DB2 procedure. Insertion is failing with the below error looks DB2 is considering the input as String rather than CLOB datatype. Can you please suggest what needs to be done?

SP

CREATE OR REPLACE PROCEDURE logging (IN HEADERDATA CLOB(10M))
LANGUAGE SQL
BEGIN
    INSERT INTO Logging(Header) VALUES (HEADERDATA);
    COMMIT;
END

Error

The string constant beginning with 
"'<?xml version="1.0" encoding="UTF-8"?><XXXXXXXX xmlns:xsi="http:" is too long.. 
SQLCODE=-102, SQLSTATE=54002, DRIVER=XXXXXX

回答1:


Character literals in DB2 are limited to about 32K bytes. To handle larger LOBs you need to avoid having to use SQL literal values.

One way to do this without extra programming is write your [future] CLOB contents to a file and use IMPORT or LOAD to insert its contents into a column.

Alternatively, you could wrap a simple Java program around your procedure call where you would use PreparedStatement.setClob() to handle your large XML document.



来源:https://stackoverflow.com/questions/44871254/unable-to-store-clob-data-in-to-clob-defined-column-in-db2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!