ORACLE provider: Passing LDA or SvcCtx to dll

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

ORACLE provider: Passing LDA or SvcCtx to dll

Post by VadimShvarts » Wed 07 May 2014 06:11

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by AlexP » Wed 07 May 2014 10:33

Hello,

No, this functionality is no available in UniDAC.

VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by VadimShvarts » Wed 07 May 2014 12:40

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by AlexP » Wed 07 May 2014 14:59

UniDAC is a universal product for working with various databases, therefore we cannot implement separate features supported by a particular database.

VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by VadimShvarts » Thu 08 May 2014 05:40

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;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by AlexP » Thu 08 May 2014 14:35

We will consider the possibility to add such functionality in one of the next versions.

VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by VadimShvarts » Wed 03 Dec 2014 07:11

We will consider the possibility to add such functionality in one of the next versions.
Any news?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by AlexP » Wed 03 Dec 2014 08:40

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.

VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by VadimShvarts » Tue 09 Dec 2014 06:46

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: ORACLE provider: Passing LDA or SvcCtx to dll

Post by AlexP » Wed 10 Dec 2014 09:12

This functionality is yet to be available in UniDAC.

Post Reply