oracle 错误:ORA-01704:字符串文字太长
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13945710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error : ORA-01704: string literal too long
提问by hsuk
While I try to set the value of over 4000 characters on a field that has data type CLOB
, it gives me this error :
当我尝试在具有数据类型的字段上设置超过 4000 个字符的值时CLOB
,它给了我这个错误:
ORA-01704: string literal too long.
ORA-01704: 字符串文字太长。
Any suggestion, which data type would be applicable for me if I have to set value of unlimited characters although for my case, it happens to be of about 15000
chars.
任何建议,如果我必须设置无限字符的值,哪种数据类型适用于我,尽管就我而言,它恰好是关于15000
字符的。
Note : The long string that I am trying to store is encoded in ANSI.
注意:我试图存储的长字符串是用 ANSI 编码的。
回答by knagaev
What are you using when operate with CLOB?
使用 CLOB 操作时您使用的是什么?
In all events you can do it with PL/SQL
在所有事件中,您都可以使用 PL/SQL
DECLARE
str varchar2(32767);
BEGIN
str := 'Very-very-...-very-very-very-very-very-very long string value';
update t1 set col1 = str;
END;
/
回答by Ameer Tamboli
Try to split the characters into multiple chunks like the query below and try:
尝试将字符拆分为多个块,如下面的查询,然后尝试:
Insert into table (clob_column) values ( to_clob( 'chunk 1' ) || to_clob( 'chunk 2' ) );
It worked for me.
它对我有用。
回答by kazzikazzi
The split work until 4000 chars depending on the characters that you are inserting. If you are inserting special characters it can fail. The only secure way is to declare a variable.
根据您插入的字符,拆分工作直到 4000 个字符。如果您插入特殊字符,它可能会失败。唯一安全的方法是声明一个变量。
回答by Seb T.
To solve this issue on my side, I had to use a combo of what was already proposed there
为了解决我这边的这个问题,我不得不使用那里已经提出的组合
DECLARE
chunk1 CLOB; chunk2 CLOB; chunk3 CLOB;
BEGIN
chunk1 := 'very long literal part 1';
chunk2 := 'very long literal part 2';
chunk3 := 'very long literal part 3';
INSERT INTO table (MY_CLOB)
SELECT ( chunk1 || chunk2 || chunk3 ) FROM dual;
END;
Hope this helps.
希望这可以帮助。