Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : ORA-01704: string literal too long

While I try to set the value of over 4000 characters on a field that has data type CLOB, it gives me this error :

ORA-01704: string literal too long.

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.

Note : The long string that I am trying to store is encoded in ANSI.

like image 872
hsuk Avatar asked Dec 19 '12 04:12

hsuk


People also ask

How do I fix Ora 01704 string literal too long?

This ORA-01704 error is related with the string literal is longer than 4000 characters. Use a string literal of at most 4000 characters. Longer values may only be entered using bind variables. You need to split the characters into multiple parts as follows.

How do I save more than 4000 characters in Oracle?

For strings greater than 4000 use a CLOB. you can use CLOB column.


2 Answers

What are you using when operate with CLOB?

In all events you can do it with 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; / 

Proof link on SQLFiddle

like image 68
knagaev Avatar answered Oct 06 '22 23:10

knagaev


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.

like image 29
Ameer Tamboli Avatar answered Oct 06 '22 22:10

Ameer Tamboli