Question

I'm testing a recently converted a database to UTF-8. If I use long random UTF-8 characters to insert into a varchar2 field (4000 characters) I get: [ORA-01704: string literal too long using long UTF-8 Character set]

If I cut the string down to about 3600 characters, it works. What gives? Is there a way to insert my 4000 characters?

Note that there are some pretty strange characters in the string.

Thanks.

Was it helpful?

Solution

From the documentation:

Independently of the maximum length in characters, the length of VARCHAR2 data cannot exceed 4000 bytes.

So a field declared as varchar2(4000 [char]) can hold 4000 single-byte characters, or a lower number of multi-byte characters. You can't get around that, at least until 12c when varchar2 supports up to 32k.

If you do actually need to allow 4000 multi-byte characters in 11g or earlier you will need to create the column as a CLOB, which can hold gigabytes of data. (You might want to read more on LOB storage as well).

OTHER TIPS

A single UTF-8 character can be more than 1 byte long. Oracle has a limit of 4000 bytes. Therefore less then 4000 UTF-8 characters will fit into a 4000 char length column.

Better you Change the datatype of the column to clob

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top