Registry TNS_ADMIN settings

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Registry TNS_ADMIN settings

Post by MarkF » Tue 12 Oct 2010 11:23

It appears that the OraServerEnum.GetTNSFileName function doesn't check HKLM\Software\Oracle\[TNS_ADMIN] for a value. I believe that it should do this if it doesn't find this value in any of the home registry locations. The Oracle Client checks this location and uses it (it's common when using Instant Client to put it there if you don't want to use an environment variable for TNS_ADMIN.) Also this function should set Result := '' at the top to avoid the result returning the passed in value if no value is found (the old result is a hidden var argument issue.)

Thanks!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 12 Oct 2010 12:14

Hello,

The GetTNSFileName function returns the correct value from registry HKLM\Software\Oracle\[TNS_ADMIN], check that you added the correct value to the registry key HKLM\Software\Oracle\[ORACLE_HOME].

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Tue 12 Oct 2010 13:48

Hi Alex,

It checks the individual registry home locations if they exist, but it does not appear to check the root location. The Oracle Client does check this location, so ODAC should as well. I've modified the code to do it, you just need to add

Code: Select all

        // Added check for tns_admin in the HKLM\software\Oracle
        if FileName = '' then
          FileName := AddPath(RegIniFile.ReadString(sOraHomeKey, sTnsAdmin, ''), sTnsNames);
Right under the if-else clause where it checks the individual homes. Thanks.

-Mark

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 15 Oct 2010 13:19

Hello,

Thank you for the information.
We added search for the TNS_ADMIN variable in the oracle root location.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Thu 09 Dec 2010 14:36

Hi Alex,

The code for this in the latest build doesn't actually work. It is:

Code: Select all

        if FileName = sTnsNames then
          FileName := AddPath(RegIniFile.ReadString(sOraHomeKey, sTnsAdmin, ''), sTnsNames);
However Filename will actually be empty there if it hasn't been found yet. The code needs to be:

Code: Select all

        if FileName = '' then
          FileName := AddPath(RegIniFile.ReadString(sOraHomeKey, sTnsAdmin, ''), sTnsNames);
Thanks,

-Mark

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 13 Dec 2010 09:26

Hello,

The FileName variable is can be empty only if the ORACLE_HOME registry value is not set, so we will add the following check:

if (FileName = sTnsNames) OR (FileName = '') then

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Mon 13 Dec 2010 12:50

Excellent! Thanks.

-Mark

Post Reply