Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle CLOB can't insert beyond 4000 characters?

How do I insert more than 4000 characters to a CLOB type column?

--create test table s
create table s
(
      a clob
);
insert into s values('>4000 char')

Results in an error:

ORA-01704:the string too long.

I want to insert a string of >4000 characters one time. How do I do it? Is it possible?

When I read the Oracle reference, CLOB can save max 4GB(Gigabyte)?

like image 317
Dolphin Avatar asked Aug 23 '13 04:08

Dolphin


People also ask

How many characters can CLOB hold in Oracle?

A CLOB (character large object) value can be up to 2,147,483,647 characters long.

What is bigger than CLOB in Oracle?

The four large object data types BFILE, BLOB, CLOB, and NCLOB all store up to 4 GB of data.

Can we insert string in CLOB Oracle?

*Cause: The string literal is longer than 4000 characters. *Action: Use a string literal of at most 4000 characters. Longer values may only be entered using bind variables.


1 Answers

  • split the long character string into 4000 character or less chunks
  • create clobs for each chunk using to_clob() function
  • concatenate the clobs

Here is an example:

insert into <table> (clob_column)
  values
  (
      to_clob(' <=4000 symbols ')
    ||to_clob(' <=4000 symbols ')
    ||to_clob(' <=4000 symbols ')
    ...
    ||to_clob(' <=4000 symbols ')
  );
like image 184
gunn Avatar answered Sep 29 '22 17:09

gunn