string literal too long - how to assign long xml data to clob data type in oracle 11g r2

妖精的绣舞 提交于 2019-12-01 14:04:21

问题


I need to assign a very large xml data of around 30,000 lines to a CLOB data type in oracle database 11g r2. I am using this command in Oracle Sql Developer.

When I use the following command, at first I get 7 prompts for entering quote value and then when statement execution completes, I get - 'string literal too long` error.

update tablename set columnName = 'large xml data' where id=1;

I used seven double (single quotes) inside the xml data to escape the single quotes.

How to assign this data to the CLOB column?


回答1:


One approach is to use sqlldr. First, create a small holding table:

create table tstclob
(
id number,
doc clob
);

Assuming your large document is the file "c:\data\test_doc.txt", create a sqlldr control file ("test_doc.ctl") to load it:

load data
infile *
replace 
into table tstclob
fields terminated by ','
(
 ID char(1),
 lob_file FILLER char,
  DOC LOBFILE(lob_file) TERMINATED BY EOF
 )
begindata
1,c:\data\test_doc.txt

Then run sqlldr (in this case, from c:\data directory):

sqlldr control=test_doc.ctl userid=someuser@somedb/somepass

You can then update whatever table you want using tstclob table.



来源:https://stackoverflow.com/questions/24161966/string-literal-too-long-how-to-assign-long-xml-data-to-clob-data-type-in-oracl

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