Finding the TNS_NAMES.ora

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MITSA

Finding the TNS_NAMES.ora

Post by MITSA » Mon 22 Nov 2004 09:08

Hello

We are using GetServerList to get a list of alias before connecting an TOraSession.

We have Oracle 10g,9,8 and 7 clients installed on the same machine.

In the registry the key Software\Oracle\Key_OraClient10g exists with a string value TNS_ADMIN which points to the centralised directory where the tns_names file exists.

The path for the oracle client is at the start of the path environemnt variable.

In the Odac help it is stated : "If HomeName property is set to '', ODAC uses first directory from the list of homes encountered in environment PATH variable as default Oracle home. "

In other words we would like to use the file specified by the tns_admin registry key in the oracle 10g home.

If the TNS_ADMIN environment variable does not exist ODAC uses the following code to try and find the registry key :

if AnsiCompareText(OracleHomeNames , OracleHomeName) = 0 then begin
FileName := AddPath(RegIniFile.ReadString(sOraHomeKey +
OracleHomeKeys, sTnsAdmin, ''), sTnsNames);

However in our case the OracleHomeName is empty and ODAC, as it can't find the registry key, looks for the tns_names file on the workstation.

What we have done to get around this "problem" is to use the following code when the OracleHomeName is empty :

if AnsiCompareText(OracleHomePaths , OracleHomePath) = 0 then
begin
FileName := AddPath(RegIniFile.ReadString(sOraHomeKey +
OracleHomeKeys, sTnsAdmin, ''), sTnsNames);

In other words we use the OracleHomePath instead of the OracleHomeName.

Is there a better way of doing this ?

Best Reagrds

Paul
MitSA

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Mon 22 Nov 2004 12:29

Thank you for information. We reproduced your problem with GetServerList and fixed it. This fix will be included in the next ODAC build.
If OracleHomeName = '' you can use OracleHomePaths[DefaultOracleHome] in this expression.

Bagieta
Posts: 21
Joined: Tue 09 Nov 2004 08:02
Location: Poland

Post by Bagieta » Wed 24 Nov 2004 14:47

I have another problem with ODAC and Oracle registry.
I'm using version 4.5 of ODAC. And on some machines with Oracle 8 client in HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE I dont have ORACLE_HOME key. Instead of it there are some subdirectories like ALL_HOMES, HOME1, HOME2 where are proper paths to tsnnames direcotry. To make it work properly, on every machine I had to create a new key ORACLE_HOME with proper path.
I need it because I also use GetServerList method.
And my question is.
Have you resolved it in future releases?
Or is there any other workaround than adding the key?

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Thu 25 Nov 2004 08:55

Please specify the exact version number of your Oracle 8 client. ORACLE_HOME key must
be in HOME1, HOME2 directories.
Please send registry structure starting from HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE to
our support email address. We will test GetServerList function.

Bagieta
Posts: 21
Joined: Tue 09 Nov 2004 08:02
Location: Poland

Post by Bagieta » Fri 26 Nov 2004 09:28

Yes there is a proper path in HOME1 and HOME2 directories but in your documentation you write that you check only ORACLE directory. And that is true because if I dont have ORACLE_HOME the ODAC cannot find tsnnames file. My Oracle client is 8.1.5.0.0

Bagieta
Posts: 21
Joined: Tue 09 Nov 2004 08:02
Location: Poland

Post by Bagieta » Fri 26 Nov 2004 09:46

Ok I have tested it with the newest controls of ODAC and it is ok now. Sorry for a trouble.

Post Reply