Page 1 of 1

Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Thu 26 Aug 2021 14:02
by jdorlon
Hello,

The subject says it all. TOraServerEnumerator.GetServerList does not look for TNS_ADMIN environment variable.

Thanks

John

Re: Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Fri 27 Aug 2021 08:50
by MaximG
Yes, the variable TNS_ADMIN is not referenced in TOraServerEnumerator.GetServerList, but is referenced earlier, in the TOracleHomes class in the OracleCall unit: procedure AddToOracleHomes(const Path, Key: string; ClientType: OralceClientType);

Re: Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Fri 27 Aug 2021 13:28
by jdorlon
Well, when I tried it (using an instant client, so no network\admin folder in my oracle home), it didn't find my tnsnames file, which can only be found using the TNS_ADMIN environment variable.

My code is like this, (where cboDatabase is a TCombobox)

Code: Select all

var
  Enum: TOraServerEnumerator;
begin
  Enum := TOraServerEnumerator.Create;
  try
    Enum.GetServerList(cboDatabase.Items);
  finally
    Enum.Free;
  end;
Is the code not intended to be used this way?

-John

Re: Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Fri 03 Sep 2021 13:12
by MaximG
Hi John!

Thanks for your reply.

The code you provided will return a list of TNS aliases for only one default ORACLE_HOME.
In this case, you can explicitly assign the default ORACLE_HOME. For example, if the Oracle InstantClient you installed is
located in the 'C:\OracleInstantClient' folder, and the TNS_ADMIN = C:\OracleInstantClient\NETWORK\ADMIN, you can change your code as follows:

Code: Select all

uses OraCall;
....

var
  Enum: TOraServerEnumerator;
begin
  Enum := TOraServerEnumerator.Create;
  try
    OracleHomes.AddHome('MyInstantClient', 'C:\OracleInstantClient');
    OracleHomes.Default := OracleHomes.GetHome('MyInstantClient');
    Enum.GetServerList(cboDatabase.Items);
  finally
    Enum.Free;
  end;
end;

Re: Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Fri 03 Sep 2021 13:15
by jdorlon
ok, thanks Maxim.

Re: Bug: TOraServerEnumerator does not check TNS_ADMIN environment variable

Posted: Tue 12 Jul 2022 04:15
by lanikane68
Your article is very good and informative, I always follow your article. You are an author that I love. Thank you for sharing! moviedle