Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

How do I insert a Swedish characters into a NVARCHAR2 Oracle table column type?

I insert it like this:

insert into s_test values('L?nsf?rs?kringar');

Getting back this:

select * from s_test;

L?nsf?rs?kringar

Here ? is a replacement char 03F

Expectation:

select * from s_test;

L?nsf?rs?kringar

Relevant NLS params:

NLS_NCHAR_CHARACTERSET  AL16UTF16
NLS_LANGUAGE    AMERICAN
NLS_TERRITORY   AMERICA
NLS_CHARACTERSET    US7ASCII
NLS_LENGTH_SEMANTICS    BYTE
NLS_RDBMS_VERSION   11.2.0.3.0

Table:

CREATE TABLE "S_TEST" 
   (    "COL1" NVARCHAR2(100) ) ;

How do I insert Swedish characgers into Oracle NVARCHAR2 column type?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use N:

insert into s_test values(N'L?nsf?rs?kringar');

https://docs.oracle.com/database/121/SQLRF/sql_elements003.htm#SQLRF00218

The syntax of text literals or strings follows:

enter image description here

where N or n specifies the literal using the national character set (NCHAR or NVARCHAR2 data). By default, text entered using this notation is translated into the national character set by way of the database character set when used by the server. To avoid potential loss of data during the text literal conversion to the database character set, set the environment variable ORA_NCHAR_LITERAL_REPLACE to TRUE. Doing so transparently replaces the n' internally and preserves the text literal for SQL processing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...