Finding the TNS_NAMES.ora
Posted: 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
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