Page 1 of 1

ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 07 May 2014 06:11
by VadimShvarts
In ODAC 9.3.8 you add such posibilites
ODAC 9.3
Possibility to assign external SvcCtx to connection is added
What about UNIDAC 5.3?

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 07 May 2014 10:33
by AlexP
Hello,

No, this functionality is no available in UniDAC.

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 07 May 2014 12:40
by VadimShvarts
Can you add to OraClassesUni.pas following procedures similar to ODAC?

Code: Select all

procedure TOCIConnection.AssignSvcCtx(hOCISvcCtx: pOCISvcCtx);
procedure TOCIConnection.AssignSvcCtx(hOCIEnv: pOCIEnv; hOCISvcCtx: pOCISvcCtx);
Thanks

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 07 May 2014 14:59
by AlexP
UniDAC is a universal product for working with various databases, therefore we cannot implement separate features supported by a particular database.

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Thu 08 May 2014 05:40
by VadimShvarts
UniDAC is a universal product for working with various databases, therefore we cannot implement separate features supported by a particular database.
But Interbase provider already has procedures in IBCClassesUni.pas and we use them to transmit DbHandle in DLL

Code: Select all

procedure TGDSConnection.SetDatabaseHandle(Value: TISC_DB_HANDLE);
How much you can't add procedure for ORACLE provider?
We don't need to broadcast them to the level TUniConnection

We use such code:

Code: Select all

 with TUniConnection(Db) do
  begin
{$IFDEF Oracle}
   if FIConnection is TOCIConnection then
    begin
     OCIConnection := (FIConnection as TOCIConnection);
     hOCISvcCtx := Pointer(PluginData.DatabaseHandle);
     if OCIConnection.Direct then
      Environment := OracleHomes.Direct.AllocEnvironment(PluginData.hOCIEnv)
     else
      begin
       Home := OracleHomes.GetHome(HomeName);
       Environment := Home.AllocEnvironment(OCIConnection.UnicodeEnvironment, 0);
      end;
     Unicode := StrToBoolDef(SpecificOptions.Values['Oracle.UseUnicode'], False);
     TempOCISvcCtx := TOCISvcCtx.Create(Environment, hOCISvcCtx, Unicode);
     OCIConnection.SetOCISvcCtx(TempOCISvcCtx);
    end;
{$ENDIF}
{$IFDEF InterBase}
   if FIConnection is TGDSConnection then
    begin
     GDSConnection := (FIConnection as TGDSConnection);
     GDSConnection.SetDatabaseHandle(Pointer(PluginData.DatabaseHandle));
    end;
{$ENDIF}
  end;
It would be better and more beautiful

Code: Select all

 with TUniConnection(Db) do
  begin
{$IFDEF Oracle}
   if FIConnection is TOCIConnection then
    begin
     OCIConnection := (FIConnection as TOCIConnection);
     hOCISvcCtx := Pointer(PluginData.DatabaseHandle);
     if OCIConnection.Direct then
      OCIConnection.AssignSvcCtx(PluginData.hOCIEnv, hOCISvcCtx)
     else
      OCIConnection.AssignSvcCtx(hOCISvcCtx);
    end;
{$ENDIF}
{$IFDEF InterBase}
   if FIConnection is TGDSConnection then
    begin
     GDSConnection := (FIConnection as TGDSConnection);
     GDSConnection.SetDatabaseHandle(Pointer(PluginData.DatabaseHandle));
    end;
{$ENDIF}
  end;

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Thu 08 May 2014 14:35
by AlexP
We will consider the possibility to add such functionality in one of the next versions.

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 03 Dec 2014 07:11
by VadimShvarts
We will consider the possibility to add such functionality in one of the next versions.
Any news?

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 03 Dec 2014 08:40
by AlexP
Below are working samples of an application and a library demonstrating work with LDA:

Project:

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Windows,
  Ora, OraCall;

type
  TAssignLDA = procedure (LDA: PLDA); cdecl;

var
  OraSession: TOraSession;
  AssignLDA: TAssignLDA;
  hDLL:HModule;
begin
  OraSession := TOraSession.Create(nil);
  try
    OraSession.ConnectString := 'scott/tiger@orcl';
    OraSession.Options.UseOCI7 := true;
    OraSession.Connect;

    hDLL := LoadLibrary('Project2.dll');
    if hDLL <> 0 then begin
      @AssignLDA := GetProcAddress(hDLL, 'AssignLDA');
      if @AssignLDA <> nil then
        AssignLDA(OraSession.LDA);
    end
  finally
    OraSession.Free;
  end;
end.
Dll:

Code: Select all

library Project2;

uses
  SysUtils,
  Classes,
  OraCall,
  Ora;

procedure AssignLDA(LDA: PLDA); cdecl;
var
  OraSession: TOraSession;
begin
  OraSession := TOraSession.Create(nil);
  try
    OraSession.Options.UseOCI7 := true;
    OraSession.AssignLDA(LDA);
    OraSession.Connect;
  finally
    OraSession.Free;
  end;
end;

exports
  AssignLDA;
begin
end.

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Tue 09 Dec 2014 06:46
by VadimShvarts
Below are working samples of an application and a library demonstrating work with LDA:
It`s very nice for ODAC!
But what about SvcCtx and UNIDAC?

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Posted: Wed 10 Dec 2014 09:12
by AlexP
This functionality is yet to be available in UniDAC.