#1 Re: mORMot 1 » Fix SynDBOracle for work under linux » 2019-03-12 08:55:06

mpv
you fix problem?

useful thing: change the version of oci to 11.2.x

#2 Re: mORMot 1 » Fix SynDBOracle for work under linux » 2018-01-08 11:28:25

It works for me.
thx!

A few words about possible problems:
1. Use only oci_11.2.0.x or later!
2. Use SynDBOracleOCIpath to specify the path where the oracle client is located
3. Required files for linux oracle client:

libclntsh.so  libclntsh.so.11.1  libnnz11.so  libocci.so  libocci.so.11.1  libociei.so

libclntsh.so and libocci.so is symlinks

#3 mORMot 1 » Fix SynDBOracle for work under linux » 2018-01-07 14:13:47

IL_S
Replies: 20

Hello!

I'm trying to use SynDBOracle in my project for a Linux server. But this unit is designed only for windows.

I've modified it and now it works fine for me.

Diff:

--- /usr/src/vcl/mormot.1.18/SynDBOracle.pas	2017-10-05 02:49:08.000000000 +0700
+++ /usr/src/vcl/wbLib/SynDBOracle.pas	2017-12-24 23:35:34.000000000 +0700
@@ -150,6 +150,8 @@
 uses
   {$ifdef MSWINDOWS}
   Windows,
+  {$else}
+  dynlibs,
   {$endif}
   SysUtils,
   {$ifndef DELPHI5OROLDER}
@@ -1802,36 +1804,52 @@
 end;
 
 constructor TSQLDBOracleLib.Create;
+const
+  {$ifdef MSWINDOWS}
+  libname = 'oci.dll';
+  {$else}
+  libname = 'libclntsh.so';
+  {$endif}
 var P: PPointer;
     i: integer;
     orhome: string;
+
+  function SafeLoadLibrary(const FileName: TFileName): HMODULE;
+  begin
+    {$ifdef MSWINDOWS}
+    Result:=SysUtils.SafeLoadLibrary(FileName);
+    {$else}
+    Result:=LoadLibrary(PAnsiChar(AnsiString(fLibraryPath)));
+    {$endif}
+  end;
+
 begin
-  fLibraryPath := 'oci.dll';
+  fLibraryPath := libname;
   if (SynDBOracleOCIpath<>'') and DirectoryExists(SynDBOracleOCIpath) then
-    fLibraryPath := ExtractFilePath(ExpandFileName(SynDBOracleOCIpath+'\'))+fLibraryPath;
+    fLibraryPath := ExtractFilePath(ExpandFileName(SynDBOracleOCIpath{+PathDelim}))+fLibraryPath;
   fHandle := SafeLoadLibrary(fLibraryPath);
   if fHandle=0 then begin
     if fHandle=0 then begin
       orhome := GetEnvironmentVariable('ORACLE_HOME');
       if orhome<>'' then begin
-        fLibraryPath := IncludeTrailingPathDelimiter(orhome)+'bin\oci.dll';
+        fLibraryPath := IncludeTrailingPathDelimiter(orhome)+'bin'+PathDelim+libname;
         fHandle := SafeLoadLibrary(fLibraryPath);
       end;
     end;
   end;
   if fHandle=0 then begin
-    fLibraryPath := ExeVersion.ProgramFilePath+'OracleInstantClient\oci.dll';
+    fLibraryPath := ExeVersion.ProgramFilePath+'OracleInstantClient'+PathDelim+libname;
     fHandle := SafeLoadLibrary(fLibraryPath);
   end;
   if fHandle=0 then
-    raise ESQLDBOracle.Create('Unable to find Oracle Client Interface (oci.dll)');
+    raise ESQLDBOracle.CreateFmt('Unable to find Oracle Client Interface (%s)',[libname]);
   P := @@ClientVersion;
   for i := 0 to High(OCI_ENTRIES) do begin
     P^ := GetProcAddress(fHandle,OCI_ENTRIES[i]);
     if P^=nil then begin
       FreeLibrary(fHandle);
       fHandle := 0;
-      raise ESQLDBOracle.CreateFmt('Invalid oci.dll: missing %s',[OCI_ENTRIES[i]]);
+      raise ESQLDBOracle.CreateFmt('Invalid %s: missing %s',[libname,OCI_ENTRIES[i]]);
     end;
     inc(P);
   end;

I would be happy if my changes were added to the source repository.

Board footer

Powered by FluxBB