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
How to POST_EVENT
Moderators: gto, EgonHugeist
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
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
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
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
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
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