Someone please explain this behavior with multi-byte characters [message #648939] |
Tue, 08 March 2016 02:59 |
|
cool.aquarian
Messages: 3 Registered: March 2016
|
Junior Member |
|
|
I am dealing with a strange behavior related to multibyte character data.
1. I have the following table:
CREATE TABLE MUTIBYTE_TEST
(
S_NO NUMBER(3),
PAYLOAD NVARCHAR2(10),
PAYLOAD2 NVARCHAR2(4000)
)
2. I try to insert below 10 character multibyte data using SQL Developer:
INSERT INTO MUTIBYTE_TEST VALUES(2,'无锡市职业病防治医院','');
It runs fine, and I can see the data.
3. I try to insert same 4000 multibyte characters into PAYLOAD2 as well (by repeating the 10 multibyte characters 400 times):
INSERT INTO MUTIBYTE_TEST VALUES(2,'无锡市职业病防治医院','无锡市职业病防治医院无锡市职业病防治医院无锡市职业病防治医院 ..... <repeated 400 times=4000 chars>');
Now I get the below error:
Error report -
SQL Error: ORA-01704: string literal too long
01704. 00000 - "string literal too long"
*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.
Why is it not allowing me to insert the same multibyte characters after repeating 400 times ?
[Updated on: Tue, 08 March 2016 03:00] Report message to a moderator
|
|
|
|
|
Re: Someone please explain this behavior with multi-byte characters [message #648951 is a reply to message #648950] |
Tue, 08 March 2016 10:56 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Because it is declared as 10 character length.
The other one is declared as 4000 character length but the internal limit is anyway 4000 bytes whatever you declare which means 4000 characters if you have single byte characters but less if you have multi-byte characters.
[Edit: NVARCHAR2 length does not depend on "nls_length_semantics", it is always defined as CHAR length]
[Updated on: Tue, 08 March 2016 11:47] Report message to a moderator
|
|
|
|
|