Link to home
Start Free TrialLog in
Avatar of jim_imtech
jim_imtech

asked on

NLS_LANG setting on SQLPLUS

I am trying to set NLS_LANG setting to POLISH_POLAND.EE8PC852 in a batch file. The batch file further executes sql files as under

set NLS_LANG=POLISH_POLAND.EE8PC852
sqlplus username/password@sid @SetLang.sql

Open in new window


SetLang.sql updates some tables in my database. When I call this bat file the special characters do not get updated in my database but when I execute the same sql from sqldeveloper they get updated.

Where am I going wrong?
Avatar of Greg Clough
Greg Clough
Flag of United Kingdom of Great Britain and Northern Ireland image

What format is the SetLang.sql file in?  I'm presuming that your database is in EE8PC852 character set, but is the SQL file in the same format... or is it in UTF-8?

Remember, you need to set the NLS_LANG to match the "client", not the "database".

Alternatively, it appears you're using csh.  Have you tried using "setenv"?

setenv NLS_LANG=POLISH_POLAND.EE8PC852

Open in new window


If you could give a dump of the SQL file (using "od"), and of the database rows (using "dump(YOUR_COLUMN_HERE,1016)") that would be helpful.
Avatar of jim_imtech
jim_imtech

ASKER

My sql file has simple update statements

update TBLDETECTOR_TYPEID set typedescription = 'Predkosc' where typedescription = 'Speed';

commit;

Open in new window


Please note the special characters in 'Predkosc' are removed....

The database column shows Pr¦Ödko+T¦ç
Using setenv  has the same result
You are right. My sql file is in UTF-8. Is that the issue? How can I save it in EE8PC852 using notepad or Notepad++?
If you set your NLS_LANG thus:

set NLS_LANG=POLISH_POLAND.AL32UTF8

Open in new window


Then Oracle will know that the file you are loading is UTF-8, and convert it to whatever character set the database is using... in this case EE8PC852.  There is a very common misconception that you need to set your NLS_LANG to match your database, but that is dangerously wrong.  Always set your NLS_LANG to match the client that's connecting to the database and let the magic of TNS character set translation sort the conversion for you.

If the character set of your client is set to match your database, then Oracle presumes there is no character translation required and loads whatever you feed it directly into the database... thus you're getting UTF-8 data in your database, but when it's read back the database is presuming it's EE8PC852.  This type of corruption is difficult if not impossible to reverse.

NOTE: I'm presuming you're on v10 or v11 of Oracle as their UTF-8 character set is AL32UTF8, as otherwise if you're on v9 or earlier then I'll have to google to remember what it was.
I am running this script from SQLPLus and looking at the link http://docs.oracle.com/html/B10546_01/gblsupp.htm there is no setting of AL32UTF8 for Dos.

I still tried it but I get SP2-0734 error. Basically sqlplus finds junk characters around my sql. Any suggestions?

I am using Oracle 11.2
ASKER CERTIFIED SOLUTION
Avatar of Greg Clough
Greg Clough
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial