Question about AfterConnect event
Posted: Fri 04 Sep 2015 10:22
Hello
I'm testing ODAC demo (9.5.18 / Delphi XE7) and i've got stupid question about TOraSession.Assign method and events
I just wanted to create universal TDataModule descendant with TOraStoredProc + TOraSession (session for testing purposes and for assigning it to the TOraStoredProc inside IDE) with posibility to attach this TDataModule to existing and connected session (because I just don't want to assign TOraStoredProc.Session dynamically for every instance of this component)
Maybe any better idea?
Why there is such a difference in events between AssignConnect and Assign methods?...
(I just wanted to use similar idea as in OdacDemo => DemoFrame.pas)
I'd be grateful for any explanation / help
After checking...
calling Assign again causes BeforeDisconnest+AfterDisconnect events
Then calling TOraStoredProc.Execute causes BeforeConnect+AfterConnect event pair...
Is this a bug or an intentional behaviour? (What is the purpose of that mechanism?)
I'm testing ODAC demo (9.5.18 / Delphi XE7) and i've got stupid question about TOraSession.Assign method and events
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, MemDS, DBAccess, Ora, OraCall, Vcl.StdCtrls;
type
TForm1 = class(TForm)
OraSession1: TOraSession;
TestStoredProc: TOraStoredProc;
Button1: TButton;
OraSession2: TOraSession;
Button2: TButton;
procedure OraSession1AfterConnect(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
OraSession1.Connect;
TestStoredProc.Session := OraSession2;
OraSession2.AssignConnect(OraSession1);
TestStoredProc.Execute; // this line works as i expected
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
OraSession1.Connect;
TestStoredProc.Session := OraSession2;
OraSession2.Assign(OraSession1);
TestStoredProc.Execute; // WHY DOES THIS LINE FIRES AfterConnect EVENT?...
end;
end.
Maybe any better idea?
Why there is such a difference in events between AssignConnect and Assign methods?...
(I just wanted to use similar idea as in OdacDemo => DemoFrame.pas)
I'd be grateful for any explanation / help

After checking...
calling Assign again causes BeforeDisconnest+AfterDisconnect events
Then calling TOraStoredProc.Execute causes BeforeConnect+AfterConnect event pair...
Is this a bug or an intentional behaviour? (What is the purpose of that mechanism?)