mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-30 08:26:36 +02:00
parent
bb00c76fe7
commit
5799ff1789
@ -3378,7 +3378,7 @@ uses ctypes,
|
|||||||
{$include ociap.inc}
|
{$include ociap.inc}
|
||||||
|
|
||||||
{$IFDEF LinkDynamically}
|
{$IFDEF LinkDynamically}
|
||||||
Procedure InitialiseOCI;
|
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
|
||||||
Procedure ReleaseOCI;
|
Procedure ReleaseOCI;
|
||||||
|
|
||||||
var OCILibraryHandle : TLibHandle;
|
var OCILibraryHandle : TLibHandle;
|
||||||
@ -3390,20 +3390,31 @@ implementation
|
|||||||
|
|
||||||
{$IFDEF LinkDynamically}
|
{$IFDEF LinkDynamically}
|
||||||
|
|
||||||
var RefCount : integer;
|
var
|
||||||
|
RefCount : integer;
|
||||||
|
LibName : AnsiString;
|
||||||
|
|
||||||
Procedure InitialiseOCI;
|
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inc(RefCount);
|
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
|
begin
|
||||||
OCILibraryHandle:=loadlibrary(ocilib);
|
OCILibraryHandle:=loadlibrary(ocilib);
|
||||||
if (OCILibraryHandle=nilhandle) then
|
if (OCILibraryHandle=nilhandle) then
|
||||||
begin
|
begin
|
||||||
RefCount := 0;
|
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;
|
end;
|
||||||
|
libName:=LibraryName;
|
||||||
|
end;
|
||||||
|
|
||||||
{ ORL.inc}
|
{ ORL.inc}
|
||||||
pointer(OCINumberInc) := GetProcedureAddress(OCILibraryHandle,'OCINumberInc');
|
pointer(OCINumberInc) := GetProcedureAddress(OCILibraryHandle,'OCINumberInc');
|
||||||
pointer(OCINumberDec) := GetProcedureAddress(OCILibraryHandle,'OCINumberDec');
|
pointer(OCINumberDec) := GetProcedureAddress(OCILibraryHandle,'OCINumberDec');
|
||||||
@ -3890,17 +3901,18 @@ begin
|
|||||||
pointer(OCIDBShutdown) := GetProcedureAddress(OCILibraryHandle,'OCIDBShutdown');
|
pointer(OCIDBShutdown) := GetProcedureAddress(OCILibraryHandle,'OCIDBShutdown');
|
||||||
pointer(OCIClientVersion) := GetProcedureAddress(OCILibraryHandle,'OCIClientVersion');
|
pointer(OCIClientVersion) := GetProcedureAddress(OCILibraryHandle,'OCIClientVersion');
|
||||||
pointer(OCIInitEventHandle) := GetProcedureAddress(OCILibraryHandle,'OCIInitEventHandle');
|
pointer(OCIInitEventHandle) := GetProcedureAddress(OCILibraryHandle,'OCIInitEventHandle');
|
||||||
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure ReleaseOCI;
|
Procedure ReleaseOCI;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if RefCount > 0 then dec(RefCount);
|
if RefCount > 0 then
|
||||||
|
dec(RefCount);
|
||||||
if RefCount = 0 then
|
if RefCount = 0 then
|
||||||
begin
|
begin
|
||||||
if not UnloadLibrary(OCILibraryHandle) then inc(RefCount);
|
if not UnloadLibrary(OCILibraryHandle) then
|
||||||
|
inc(RefCount);
|
||||||
|
LibName:='';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user