olekb
olekb

Reputation: 648

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 \003F

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?

Upvotes: 0

Views: 2592

Answers (1)

krokodilko
krokodilko

Reputation: 36107

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.

Upvotes: 1

Related Questions