Page 1 of 1
How to POST_EVENT
Posted: 09.11.2009, 17:24
by kerino
Hi,
Using Delphi 5, Firebird 2.1, and ZEOSLib 6.6.5
I've been trying to use POST_EVENT, which I thought would be straightforward - so I tried
ZQuery1.SQL.Text := 'POST_EVENT ''my_event''';
ZQuery1.ExecSQL;
I get the Dynamic SQL error message, invalid token line 1 column 1.
This is saying the POST_EVENT is an invalid token.
Could somebody please explain to me how to post events, as this method obviously does not work.
Many thanks
Kerin
Posted: 09.11.2009, 21:29
by seawolf
You can use POST_EVENT inside a stored procedure or a trigger, like this
CREATE PROCEDURE SEND_CUSTOM(
EVENT_NAME VARCHAR(127) CHARACTER SET WIN1251,
INFO VARCHAR(255) CHARACTER SET WIN1251 DEFAULT NULL)
RETURNS(
GIVEBACK VARCHAR(255) CHARACTER SET WIN1251)
AS
BEGIN
POST_EVENT event_name;
GIVEBACK = INFO;
SUSPEND;
END;
and then execute it. To catch that event on delphi use TIBEventAlerter component
Posted: 10.11.2009, 11:18
by kerino
Thank you very much seawolf. Very helpful.
I am now creating a stored procedure as follows:-
with ZQuery1 do
begin
SQL.Text := 'CREATE PROCEDURE MY_REFRESH';
SQL.Add('AS BEGIN');
SQL.Add('POST_EVENT ''my_event'';');
SQL.Add('END');
ExecSQL;
end;
I then drop a StoredProc component on the form, set the connection, and select MY_REFRESH in the SrotedProcName parameter.
When I try to execute it however, using
ZStoredProc1.ExecProc;
I get an error "-501 Attempt to reclose a closed cursor."
Being rather new to Firebird and Zeos, I don't really know what I'm doing wrong.
Can you help please?
Many thanks
Kerin
Posted: 11.11.2009, 07:49
by seawolf
every stored procedure, in Firebird, must begin with
SET TERM ^ ;
end finish with
SET TERM ; ^
Moreover change SQL.Add('END'); to SQL.Add('END;');
Posted: 13.11.2009, 21:14
by kerino
Thanks seawolf, and sorry for the delay in responding.
There was actually a ; in the last END (typo)
I tried putting in the SET TERM lines, but I got an error
Unknown token - line 1 column 5 TERM, error code -104
Seems to work better without them.
I checked with Firebird Maestro, and the procedure is there now.
I can now post events OK (I think
)
Now I have to try and catch them...
Many thanks - Kerin