Gen

 View Only

 Accessing Gen API from .Net getting Error regarding NLS_LANG.

Gintaras Svalbonas's profile image
Gintaras Svalbonas posted Dec 17, 2021 04:33 AM
Hello we have an Encyclopedia on Oracle.
The DB NLS_LANG is AMERICAN_AMERICA.WE8ISO8859P15.

I am using the same code that is working with Gen8.5.
So in order to comply with NLS_LANG I have the code below:
 Environment.SetEnvironmentVariable(
 "NLS_LANG",
 string.IsNullOrWhiteSpace(gen8EncyInfo.NlsLang)? "AMERICAN_AMERICA.WE8ISO8859P1": gen8EncyInfo.NlsLang,
 EnvironmentVariableTarget.Process);​

Where gen8EncyInfo.NlsLang for Gen8.6 is AMERICAN_AMERICA.WE8ISO8859P15.

So when I load the ueapi32.dll and calling EApiConnectToEncy the app crashes with the error log below:

DATABASE CONNECT ERROR: characterset inconsistency,
NLS_LANG characterset must match NLS_CHARACTERSET!
DBNAME= NLS_CHARACTERSET=WE8ISO8859P15 NLS_LANG=(null)​


But If first call Gen8.5 and then try to connect to Gen8.6 I got the same error but the NLS_LANG is not null but previous one of Gen8.5.

DATABASE CONNECT ERROR: characterset inconsistency,
NLS_LANG characterset must match NLS_CHARACTERSET!
DBNAME= NLS_CHARACTERSET=WE8ISO8859P15 NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

THNX

Lynn Williams's profile image
Broadcom Employee Lynn Williams
Hi @Gintaras Svalbonas
As you are probably aware the NLS_LANG versus DB NLS_CHARACSERTSET check in Gen Oracle CSE is to prevent unwanted Oracle character conversions because Gen CSE does its own character conversion e.g. KB article: "NLS_LANG characterset must match NLS_CHARACTERSET" on Gen CSE service/iefmd startup

Assuming you are not running this on CSE itself, have you tested 8.6 CSE access via API by just setting NS_LANG=AMERICAN_AMERICA.WE8ISO8859P15 as Windows System Environment variable on your Windows environment? Just to see if that will work without using the code to set environment variable NLS_LANG.

Thanks

Lynn

Gintaras Svalbonas's profile image
Gintaras Svalbonas
Hi @Lynn Williams,
Actually this is a work around by setting User Environments Variable.

But the problem is, that all of our customers are at Gen 8.5 and we are in migration phase. So some of our customers will get a new version of the product with Gen8.6. But rest will be still in Gen8.5.

My goal is to keep working with both version of Gen. That's why I am setting Process Environments Variable instead of User or System. This way I can control, per process, which version of Gen I am working at the moment. And for some reason Gen API is ignoring Process Environments Variable, this the issue.

Thanks,
Gintaras Svalbonas​​
Lynn Williams's profile image
Broadcom Employee Lynn Williams

Hi @Gintaras Svalbonas
Thanks for the extra explanation.
Is running your program from a .bat/.cmd file feasible/acceptable workaround for 8.5/8.6 mixed environment where in that file you first set NLS_LANG before you call the program? i.e. you have separate .bat/.cmd files for 8.5 and 8.6. 

Regards,

Lynn

Gintaras Svalbonas's profile image
Gintaras Svalbonas
Hi @Lynn Williams
This is our versioning application. It is written in C#. User will select one of 2 Gen environment for versioning. So it is unknown from the start, which Gen with, the app will work. That is why I am setting Environment Parameters in code, to comply with each Gen version requirements.

By the way, Gen8.5 works fine. We had Gen8.5 & Gen8.0 on the same PC and this technique was working back then. Now, as I sad, Gen8.6 ignores Process Environment Parameters.

Also running cmd script like this works:
SETLOCAL
SET PATH=%GEN86JRE%bin;%GEN86%gen;%GEN86%client;%GEN86%cse\bin;%GEN86%cse\cse_oracle;%PATH%
SET NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15​

As you can see I use SETLOCAL, that means environment parameters will be set only for the process.

Thanks,
Gintaras Svalbonas​
Lynn Williams's profile image
Broadcom Employee Lynn Williams
I can't explain why this is not working with Gen 8.6 CSE API if it worked in previous 8.0 and 8.5 versions.
At this time I cannot easily check if anything has changed in the API because our CSE SME in Engineering is out until January due to the holiday season.
The 8.6 API would have been rebuilt with later Visual Studio version, but I don't know if anything changed that might impact what you are seeing.
To see if this might be .NET related, instead of your C# program are you able to test a basic C/C++ program using function SetEnvironmentVariable just to check if it shows the same problem behaviour when EApiConnectToEncy is called?
 
Thanks
 
Lynn