mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-29 09:46:37 +02:00
parent
bb00c76fe7
commit
5799ff1789
@ -3378,7 +3378,7 @@ uses ctypes,
|
||||
{$include ociap.inc}
|
||||
|
||||
{$IFDEF LinkDynamically}
|
||||
Procedure InitialiseOCI;
|
||||
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
|
||||
Procedure ReleaseOCI;
|
||||
|
||||
var OCILibraryHandle : TLibHandle;
|
||||
@ -3390,20 +3390,31 @@ implementation
|
||||
|
||||
{$IFDEF LinkDynamically}
|
||||
|
||||
var RefCount : integer;
|
||||
var
|
||||
RefCount : integer;
|
||||
LibName : AnsiString;
|
||||
|
||||
Procedure InitialiseOCI;
|
||||
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
|
||||
|
||||
begin
|
||||
inc(RefCount);
|
||||
if RefCount = 1 then
|
||||
if RefCount > 1 then
|
||||
begin
|
||||
if CompareText(LibName,LibraryName)<>0 then
|
||||
Raise EInOutError.CreateFmt('Can not load Oracle client library "%s". it is already loaded as "%s".',[LibraryName,LibName]);
|
||||
exit;
|
||||
end
|
||||
else
|
||||
begin
|
||||
OCILibraryHandle:=loadlibrary(ocilib);
|
||||
if (OCILibraryHandle=nilhandle) then
|
||||
begin
|
||||
RefCount := 0;
|
||||
Raise EInOutError.Create('Can not load Oracle client. Is it installed? ('+ocilib+')');
|
||||
Raise EInOutError.CreateFmt('Can not load Oracle client library "%s". Is it installed?',[LibraryName]);
|
||||
end;
|
||||
libName:=LibraryName;
|
||||
end;
|
||||
|
||||
{ ORL.inc}
|
||||
pointer(OCINumberInc) := GetProcedureAddress(OCILibraryHandle,'OCINumberInc');
|
||||
pointer(OCINumberDec) := GetProcedureAddress(OCILibraryHandle,'OCINumberDec');
|
||||
@ -3890,17 +3901,18 @@ begin
|
||||
pointer(OCIDBShutdown) := GetProcedureAddress(OCILibraryHandle,'OCIDBShutdown');
|
||||
pointer(OCIClientVersion) := GetProcedureAddress(OCILibraryHandle,'OCIClientVersion');
|
||||
pointer(OCIInitEventHandle) := GetProcedureAddress(OCILibraryHandle,'OCIInitEventHandle');
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure ReleaseOCI;
|
||||
|
||||
begin
|
||||
if RefCount > 0 then dec(RefCount);
|
||||
if RefCount > 0 then
|
||||
dec(RefCount);
|
||||
if RefCount = 0 then
|
||||
begin
|
||||
if not UnloadLibrary(OCILibraryHandle) then inc(RefCount);
|
||||
if not UnloadLibrary(OCILibraryHandle) then
|
||||
inc(RefCount);
|
||||
LibName:='';
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user