Page 1 of 1

How use post_event in Lazarus (Firebird)

Posted: 28.12.2008, 12:42
by Fortuna1
1) I put this in my Firebired base;


CREATE TRIGGER "My_table_MSG" FOR "My_table"
ACTIVE AFTER INSERT POSITION 0
AS
beg
POST_EVENT 'my_event';
end


2 I put ZConnection1 and ZIBEventAlerter1 and ZQuery1 on my form
ZConnection1.Contected:=false;
ZConnection1.AutoCommit:=true;


ZIBEventAlerter.Conection:=ZConnection1;

ZIBEventAlerter1.AutoRegister:=False;

ZIBEventAlerter1.Register:=False;
ZIBEventAlerter1.Events[0]:='my_event';

ZConnection1.Contected:=]true;
ZIBEventAlerter1.RegisterEvents;

ZIBEventAlerter1.Register:=True;

and then dead

constructor TIBEventThread.Create(Owner: TZIBEventAlerter;
EventGrp: integer; TermEvent: TNotifyEvent);
begin
inherited Create(True); <-------------------------------------Drop dead
FCancelAlerts := False;
Signal := TSimpleEvent.Create;
Parent := Owner;
EventGroup := EventGrp;
OnTerminate := TermEvent;
Resume;
end;


What is wrong.

Thanks

Posted: 29.12.2008, 14:58
by seawolf
Which Firebird version are you using? Embedded or SS?

And What if you do not register any events? Does the app hangs?

Posted: 30.12.2008, 18:54
by Fortuna1
I m using SS.
How register any events?

Posted: 31.12.2008, 17:01
by seawolf
Supposing you are using Firebrid 2.1, and you have set it as driver in ZConnection1, open

..\src\component\ZIBEventAlerter.pas

and add

uses
SysUtils, Classes, Math,
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF}
{$IFDEF LINUX}
Libc,
{$ENDIF}
ZDbcInterbase6, ZPlainInterbaseDriver, ZConnection, ZDbcIntfs,
ZPlainInterbase5, ZPlainInterbase6, ZPlainFirebird10, ZPlainFirebird15, ZPlainFirebird20, ZPlainFirebird21, ZPlainFirebirdInterbaseConstants;

procedure TIBEventThread.RegisterEvents;

if Parent.Connection.Protocol='interbase-5' then
sib_event_block := Tsib_event_block(ZPlainInterbase5.isc_event_block)
else if Parent.Connection.Protocol='interbase-6' then
sib_event_block := Tsib_event_block(ZPlainInterbase6.isc_event_block)
else if Parent.Connection.Protocol='firebird-1.0' then
sib_event_block := Tsib_event_block(ZPlainFirebird10.isc_event_block)
else if Parent.Connection.Protocol='firebird-1.5' then
sib_event_block := Tsib_event_block(ZPlainFirebird15.isc_event_block)
else if Parent.Connection.Protocol='firebirdd-1.5' then
sib_event_block := Tsib_event_block(ZPlainFirebird15.isc_event_block)
else if Parent.Connection.Protocol='firebird-2.0' then
sib_event_block := Tsib_event_block(ZPlainFirebird20.isc_event_block)
else if Parent.Connection.Protocol='firebirdd-2.0' then
sib_event_block := Tsib_event_block(ZPlainFirebird20.isc_event_block)
else if Parent.Connection.Protocol='firebird-2.1' then
sib_event_block := Tsib_event_block(ZPlainFirebird21.isc_event_block)
else if Parent.Connection.Protocol='firebirdd-2.1' then
sib_event_block := Tsib_event_block(ZPlainFirebird21.isc_event_block)

Posted: 03.01.2009, 11:46
by mdaems
Did this change to testing branch. Will be added to 6.6-patches branch soon.

Fortuna1,
Did this solve the problem?

Mark

Posted: 29.01.2010, 10:53
by mvolovich
mdaems wrote:Did this change to testing branch. Will be added to 6.6-patches branch soon.

Fortuna1,
Did this solve the problem?

Mark
I have same problem with TZIBEventAlerter, it die in same place in ZIBEventAlerter.pas and throw RunError(232).. I use lastest version of ZEOS from SVN (7.0.0) installed in lazarus on linux.