OCI Version
OCI Version
How I can learn through ODAC
1) no installed oracle client
2) Installed x32 oracle client
3) Installed x64 oracle client
?
1) no installed oracle client
2) Installed x32 oracle client
3) Installed x64 oracle client
?
Re: OCI Version
hello,
The following code demonstrates search for installed Oracle clients and defining the library version
The following code demonstrates search for installed Oracle clients and defining the library version
Code: Select all
uses ..,Ora, Oracall;
....
function GetLibType(const AFileName: string): string;
var
oFS: TFileStream;
iPeOffset: Integer;
iPeHead: LongWord;
iMachineType: Word;
begin
Result := 'Unknown';
try
if not FileExists(AFileName) then Exit;
oFS := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone);
try
oFS.Seek($3C, soFromBeginning);
oFS.Read(iPeOffset, SizeOf(iPeOffset));
oFS.Seek(iPeOffset, soFromBeginning);
oFS.Read(iPeHead, SizeOf(iPeHead));
if iPeHead <> $00004550 then
Exit;
oFS.Read(iMachineType, SizeOf(iMachineType));
case iMachineType of
$8664,$0200: Result := '64-bit';
$014C: Result := '32-bit';
else
Result := 'Other';
end;
finally
oFS.Free;
end;
except
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
Var
i: integer;
begin
DetectOCI;
if OracleHomeCount = 0 then
begin
ShowMessage('Oracle client doesn''t installed');
exit;
end;
for i:= 1 to OracleHomeCount do
begin
ShowMessage(Format('Oracle HomeName : %s, Oracle library: %s ',[OracleHomeNames[i], GetLibType(OracleHomePaths[i]+'\bin\oci.dll')]));
end;
end;Re: OCI Version
I just wanted to add that I think that the OracleHomeCount can be 0 (zero) if the customer is using the Oracle Instant Client (which is becoming very common.)
-Mark
-Mark
Re: OCI Version
hello,
If Oracle Instant Client is used and the data about this client is not inserted into the registry and Environment Variables, it is impossible to define its presence and capacity without explicit knowledge about the directory, where it is located. If this directory is known or the client is located in the same directory as the application, then its directory can be defined with the help of the above method.
If Oracle Instant Client is used and the data about this client is not inserted into the registry and Environment Variables, it is impossible to define its presence and capacity without explicit knowledge about the directory, where it is located. If this directory is known or the client is located in the same directory as the application, then its directory can be defined with the help of the above method.
Re: OCI Version
Hi Alex,
The Instant Client installation instructions recommend putting the directory first in the system path. There won't be an Oracle Home, but the client will certainly load correctly and it will be a mistake to put up "Oracle client doesn't installed" (sic) in that case.
Just trying to help.
-Mark
The Instant Client installation instructions recommend putting the directory first in the system path. There won't be an Oracle Home, but the client will certainly load correctly and it will be a mistake to put up "Oracle client doesn't installed" (sic) in that case.
Just trying to help.
-Mark
Re: OCI Version
hello,
Placing the path to Instant Client into Environment Variables allows applications to search needed files and libraries in this path, but it doesn't describe the Oracle client, therefore we don't know what is directly in the paths included to Environment Variables, and we cannot define that it is an Oracle client. Therefore, for correct work, we recommend to add data about Instant Client to a standard registry branch.
Placing the path to Instant Client into Environment Variables allows applications to search needed files and libraries in this path, but it doesn't describe the Oracle client, therefore we don't know what is directly in the paths included to Environment Variables, and we cannot define that it is an Oracle client. Therefore, for correct work, we recommend to add data about Instant Client to a standard registry branch.
Re: OCI Version
Hi Alex,
Thanks, I'm glad that we both agree that the Oracle Home Count can be zero and the client will work perfectly.
-Mark
Thanks, I'm glad that we both agree that the Oracle Home Count can be zero and the client will work perfectly.
-Mark
Re: OCI Version
hello,
Yes, in this case OracleHomeCount will be 0, but since the path to the library is in Environment Variables, the application will find the library and work with it.
Yes, in this case OracleHomeCount will be 0, but since the path to the library is in Environment Variables, the application will find the library and work with it.
Re: OCI Version
Also if the exe is located in the Oracle dll directory there doesn't even need to be the path change (though I don't recommend that configuration in general.)
-Mark
-Mark
Re: OCI Version
hello,
Yes, if to place an application to a folder with Oracle client libraries, there will be no need to add any changes to the registry and Environment Variables, since the application searches for the necessary libraries in the current folder as well.
Yes, if to place an application to a folder with Oracle client libraries, there will be no need to add any changes to the registry and Environment Variables, since the application searches for the necessary libraries in the current folder as well.
Re: OCI Version
Thanks AlexP!
Please show variant include instant client.
ShowMessage(IntToStr(Length(OracleHomes))); // result 0
Please show variant include instant client.
ShowMessage(IntToStr(Length(OracleHomes))); // result 0
Re: OCI Version
Hello,
Since the data about the client is not included to the registry and environment variables, the OracleHomes array cannot be filled in, since a search for Oracle clients won't give results. However, in this case, the libraries and the tnsnames.ora file located in the application folder will be used.
Since the data about the client is not included to the registry and environment variables, the OracleHomes array cannot be filled in, since a search for Oracle clients won't give results. However, in this case, the libraries and the tnsnames.ora file located in the application folder will be used.
Re: OCI Version
But I have environment variable ORACLE_HOME=C:\Program Files\instantclient_11_2AlexP wrote: Since the data about the client is not included to the registry and environment variables
where exists C:\Program Files\instantclient_11_2\oci.exe
Re: OCI Version
hello,
The data about the clients (Key, Name, Path), whose data is in the registry, is inserted to OracleHomes, as in the PATH variable (not ORACLE_HOME) there is only a path to a library used by the OS for searching libraries. If there is no data about the client in the registry, then, regardless of whether there is or there is no path to the client in the PATH variable, the data won't be inserted to OracleHomes. However, if you have installed only one Instant Client and the data about it is included in this variable, then, when attempting to load the OCI.DLL library, the OS will automatically search for it on all the paths specified in this variable.
The data about the clients (Key, Name, Path), whose data is in the registry, is inserted to OracleHomes, as in the PATH variable (not ORACLE_HOME) there is only a path to a library used by the OS for searching libraries. If there is no data about the client in the registry, then, regardless of whether there is or there is no path to the client in the PATH variable, the data won't be inserted to OracleHomes. However, if you have installed only one Instant Client and the data about it is included in this variable, then, when attempting to load the OCI.DLL library, the OS will automatically search for it on all the paths specified in this variable.
Re: OCI Version
strangely what
returned true file, but Length(OracleHomes) = 0.
May be you have analog GetTNSFileName as GetOCIPath for current oci.dll?
Is there a way to get information about oci.dll instant client before a connection?
Code: Select all
var
t : TOraServerEnumerator;
begin
t := TOraServerEnumerator.Create;
Result := t.GetTNSFileName;May be you have analog GetTNSFileName as GetOCIPath for current oci.dll?
Is there a way to get information about oci.dll instant client before a connection?