NLS_LANG issues

Hi,

I'm trying to set NLS_LANG from code before logging on to the database, but keep running into some very odd issues.

There are two sequences of code that I've tried:

Code:
SetEnvironmentVariable('NLS_LANG', PChar('.' + VALID_CHARSETS[g_nCharSet][0]));
p_oraSession.Logon;

Code:
SetEnvironmentVariable('NLS_LANG', '.EL8MSWIN1253');
p_oraSession.Logon;
In the first sequence, VALID_CHARSETS is a constant two-dimensional array of string, and g_nCharSet is fetched from an INI file. In the second sequence, the specific value that is retrieved using the VALID_CHARSETS array is set as a literal. I am one hundred procent sure the argument in both sequences is the same (verified with logging and if structures), without any whitespace.

The second sequence works to fetch data as greek, the first doesn't. No other changes are in my code. If I fetch the value using GetEnvironmentVariable before I call Logon in both cases ".EL8MSWIN1253" is returned.

Any ideas on what may be causing this?

Thank you.
 
There must be some difference. Try a GetEnvironmentVariable after setting it, to verify that in both cases they are the same.
 
I have already tried calling GetEnvironmentVariable, and the value is indeed changed (correct), both before and after the call to Logon. For some reason the Oracle session is just not picking it up.

I've been trying to debug this with a co-worker for over a day, we're completely baffled by this behavior because it makes no sense whatsoever.

If it is any help, this code is in a service.
 
Back
Top