简体   繁体   English

字符串文字太长-如何在oracle 11g r2中将长xml数据分配给clob数据类型

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

I need to assign a very large xml data of around 30,000 lines to a CLOB data type in oracle database 11g r2. 我需要为Oracle数据库11g r2中的CLOB数据类型分配大约30,000行的非常大的xml数据。 I am using this command in Oracle Sql Developer. 我在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. 当我使用以下命令时,首先会得到7条提示,要求entering quote value ,然后在语句执行完成时,出现“字符串文字太长”错误。

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. 我在xml数据中使用了七个双引号(单引号)来转义单引号。

How to assign this data to the CLOB column? 如何将此数据分配给CLOB列?

One approach is to use sqlldr. 一种方法是使用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: 假设您的大型文档是文件“ c:\\ data \\ test_doc.txt”,请创建一个sqlldr控制文件(“ test_doc.ctl”)以加载该文件:

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(在这种情况下,从c:\\ data目录):

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

You can then update whatever table you want using tstclob table. 然后,您可以使用tstclob表更新所需的任何表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM