How to POST_EVENT

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
kerino
Junior Boarder
Junior Boarder
Posts: 27
Joined: 26.06.2008, 10:04

How to POST_EVENT

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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
kerino
Junior Boarder
Junior Boarder
Posts: 27
Joined: 26.06.2008, 10:04

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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;');
kerino
Junior Boarder
Junior Boarder
Posts: 27
Joined: 26.06.2008, 10:04

Post 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
Post Reply