0
votes

I am inserting data via java code by fetching it from one DB and then inserting it into other system using its own API. I am printing the size of string before setting that string as name for the record and have put a check as well, if it exceeds more than 250 character then trim it to 250 characters. So name variable in java code always print length either 250 or less than that depending on the length of value of column. Even though it always less than or equal to 250 character but I am still getting error

ORA-12899: value too large for column "OWNER"."PROJECT"."NAME" (actual: 515, maximum: 250)

The target db column is having data type varchar(250 Byte)

enter image description here

I am facing this issue if name column is having Japanese or non English characters? Does anyone have any idea what to do at code level to prevent it?

P.S. The DB is Oracle 12c

I cannot show the code, due to some restriction. But I have double verified the code and it seems to be working fine for setting name with only english characters.

1
PLease show the table/column definition and some code. - OldProgrammer
Is it 250 bytes in Oracle, or 250 Characters - VARCHAR or NVARCHAR - these details will matter - Andrew

1 Answers

2
votes

Non english characters are stored with 2 bytes in Oracle DB according to this: https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9528307800346242780 So your problem is probably that the 250 characters are UTF-8 encoded non english characters and thus need 2 byte storage. Hence the overflow.

A solution could be to change definition of column length to 250 chars, not 250 bytes.