30 September 2015

Oracle - Multi-lingual data being saved as inverted question mark

Few days back, we were trying to saving multi-lingual data in Oracle 10g database. We did all the necessary settings of setting Oracle database viz.

Setting NLS_CHARACTERSET to WE8MSWIN1252
Setting NLS_NCHAR_CHARACTERSET to AL16UTF16
Used Column Type as NVARCHAR2 or NCLOB for storing multi-lingual data.

However when we tried to store/retrieve multi-lingual data, either via client (SQL*PLUS or TOAD) or via our application (.NET based), the data was stored as inverted question mark.

Finally after a lot of search on internet, we found a simple solution for this.

The catch is to set one environment variable on client side. This can be permanently set in system environment variables or can be temporarily set for the session in .NET code.

Set ORA_NCHAR_LITERAL_REPLACE to TRUE

If we have to set this in .NET for the current session, use following statement in your .NET code -

System.Environment.SetEnvironmentVariable("ORA_NCHAR_LITERAL_REPLACE", "TRUE");

Hope this will help someone as we spent about a week finding solution for this problem.

No comments: