Page 1 of 1
AssignSvcCtx, how to use it properly?
Posted: Mon 05 May 2014 05:04
by DmitryV
ODAC 9.3
Possibility to assign external SvcCtx to connection is added
Hi, I want passing connection to dll, and try for testing...
Code: Select all
OraSession1.Connect; // this is main session
OraQuery1.Sql.Text := 'select sysdate as d from dual';
OraQuery1.Session := OraSession2;
OraSession2.AssignSvcCtx(OraSession1.OCISvcCtx);
if OraSession2.Connected then
// OraSession2 is connected now, it's right
OraQuery1.Open;
// this method returns OCI_INVALID_HANDLE
ODAC 9.3.8, ORACLE 11.2.0.1.0
Delphi XE5, Win7
Re: AssignSvcCtx, how to use it properly?
Posted: Mon 05 May 2014 07:47
by llleo
Now TOraSession.OCISvcCtx is not pointer to SvcCtx in oracle clients.
Try to use
Code: Select all
OraSession2.AssignSvcCtx(OraSession1.OCISvcCtx.hOCISvcCtx);
Re: AssignSvcCtx, how to use it properly?
Posted: Mon 05 May 2014 08:54
by DmitryV
Yes, indeed...

Thank you very much!
Re: AssignSvcCtx, how to use it properly?
Posted: Mon 05 May 2014 11:42
by llleo
This way working, but SetLDA is making AV:
Code: Select all
OraSession1.Password:=***;
OraSession1.Server:=***;
OraSession1.Options.UseOCI7:=True;
OraSession1.Connect;
OraSession2.OCISvcCtx.SetLDA(OraSession1.LDA);
making AV because of OCISvcCtx is nil.
How i can assign external LDA(or translate it into SvcCtx)?
Re: AssignSvcCtx, how to use it properly?
Posted: Tue 06 May 2014 09:38
by llleo
Still waiting for comments from support......
Re: AssignSvcCtx, how to use it properly?
Posted: Wed 07 May 2014 10:08
by AlexP
The SetLDA method is obsolete, it was left for support for protocol version 7. If you are using Oracle 11, you should work with hOCISvcCtx.
Re: AssignSvcCtx, how to use it properly?
Posted: Thu 08 May 2014 05:42
by llleo
Strange answer....
In common situation i use OciSvc with oracle 9+, but in some situation i need protocol version 7 support.
I searching way to pass LDA pointer from other DAC(with ONLY OCI7 protocol) to ODAC session(it`s not important for me - in OCI7 or OCI8 mode).
How i can use this(or any other working) method to pass external LDA(or convert to SvcCtx)?
Re: AssignSvcCtx, how to use it properly?
Posted: Tue 13 May 2014 12:18
by AlexP
Please provide your working sample of LDA setup on the old ODAC versions (also, specify the previous ODAC version).
Re: AssignSvcCtx, how to use it properly?
Posted: Tue 13 May 2014 13:37
by llleo
I have a unit with helper class (under the influence of you TBDESession):
Code: Select all
unit uSharedOraSession;
interface
uses
ORA, OraCall, DBAccess, classes, OraClasses, CRAccess;
type
TSharedOraSession = class(TOraSession)
protected
FpLDA : Pointer;
FpSVC : Pointer;
procedure DoConnect; override;
procedure DoDisconnect; override;
procedure SetIConnection(Value: TCRConnection); override;
public
constructor Create(Owner: TComponent; aLDA, aSVC : Pointer); reintroduce;
procedure CopyConnect(aSession: TOraSession);
end;
implementation
procedure TSharedOraSession.SetIConnection(Value: TCRConnection);
begin
inherited;
FIConnection := Value as TOCIConnection;
end;
procedure TSharedOraSession.DoConnect;
begin
if not OCIInited then
InitOCI;
CreateIConnection;
Pooling:=False;
if Options.UseOCI7 then
begin
FIConnection.SetOCICallStyle(OCI73);
FIConnection.SetLDA(FpLDA);
end
else
begin
FIConnection.SetOCICallStyle(OraCall.OCICallStyle);
FIConnection.SetSvcCtx(FpSVC)
end;
inherited;
end;
procedure TSharedOraSession.DoDisconnect;
begin
try
if Options.UseOCI7 then
FIConnection.SetLDA(nil)
else
FIConnection.SetSvcCtx(nil);
except
on E: EDAError do
begin
if not((csDestroying in ComponentState) and E.IsFatalError) then
Raise;
end
else
Raise;
end;
end;
constructor TSharedOraSession.Create(Owner: TComponent; aLDA, aSVC : Pointer);
begin
inherited Create(Owner);
FpLDA := aLDA;
FpSVC := aSVC;
ConnectPrompt := False;
Options.EnableIntegers := False;
Options.NeverConnect := True;
Options.UseOCI7 := not Assigned(aSVC);
end;
procedure TSharedOraSession.CopyConnect(aSession: TOraSession);
begin
if Assigned(aSession) then
begin
aSession.Options.UseOCI7 := Options.UseOCI7;
aSession.AssignConnect(Self);
end;
end;
end.
I have a form
Code: Select all
object DBGrid1: TDBGrid
DataSource = DataSource1
end
object Button1: TButton
OnClick = Button1Click
end
object OraSession1: TOraSession
Options.UseOCI7 = True
end
object OraSession2: TOraSession
Options.UseOCI7 = True
end
object OraQuery1: TOraQuery
Session = OraSession2
SQL.Strings = (
'select * from all_objects')
end
object DataSource1: TDataSource
DataSet = OraQuery1
end
And this working simple code for testing:
Code: Select all
with TSharedOraSession.Create(nil,OraSession1.LDA,nil) do
try
Connect;
CopyConnect(OraSession2);
Disconnect;
finally
Free;
end;
OraQuery1.Session:=OraSession2;
OraQuery1.Open;
This work very well in production with ODAC 4.05, 4.50, 6.50 (maybe 6.90) with a little changes(like
vs
etc). While you not changed initialization procedure.
Hope this sample is enough?
Re: AssignSvcCtx, how to use it properly?
Posted: Wed 14 May 2014 08:22
by AlexP
Thank you for the sample. We will try to return the old behavior to the next build.
Re: AssignSvcCtx, how to use it properly?
Posted: Tue 27 May 2014 08:41
by AlexP
We have added the new method for using LDA - AssignLDA. This feature will be included in the next ODAC build.
Re: AssignSvcCtx, how to use it properly?
Posted: Fri 30 May 2014 11:59
by llleo
Can you give working sample - how to use AssignLDA ?
something like
Code: Select all
OraSession1.Create;
OraSession1.Connect;
...
OraSession2.AssignLDA(OraSession1.LDA);
I try some different combination and all of then is non-worknig....
Re: AssignSvcCtx, how to use it properly?
Posted: Fri 30 May 2014 13:42
by AlexP
The provided code is correct. Please describe in more details the difficulties appearing when using the AssignLDA method.
Re: AssignSvcCtx, how to use it properly?
Posted: Tue 03 Jun 2014 10:50
by llleo
I think my problem in UseOCI7 (
http://forums.devart.com/viewtopic.php?f=5&t=29705)
I terminate my experiments until solution on this problem.
Re: AssignSvcCtx, how to use it properly?
Posted: Wed 04 Jun 2014 06:27
by AlexP
We haven't yet found a solution for the problem, we are still investigating the issue.