sp_SignalEvent

Advantage SQL Engine

  Previous topic Next topic  

This procedure provides the mechanism by which an application can cause an event notification to be signaled. For security reasons, on dictionary-bound connections sp_SignalEvent can only be called by a trigger or a stored procedure. If you want to be able to signal an event from a client with a simple SQL statement execution, you can create your own stored procedure that wraps this system procedure.

 

The EventData parameter is used to pass event data to the event.  Typically the event data is used to give the recipient of the signal enough information to locate the table or record that was updated.  The primary key or ROWID value from the updated table are good values to use to locate the updated record.  Any string data can be sent to the event, Advantage simply passes it through the events subsystem.  Note that only events that are created with the ADS_EVENT_WITH_DATA option can receive event data from a signal.  See sp_CreateEvent for more information.

Syntax

sp_SignalEvent( EventName, char, 200,

               WaitForCommit, logical,

               Options, integer );

 

sp_SignalEvent( EventName, char, 200,

               WaitForCommit, logical,

               Options, integer,

               EventData, memo

               );

WaitForCommit, logical,

Options, integer

);

Parameters

EventName (I)

Name of the event to signal

WaitForCommit (I)

This indicates if the event is to be signaled at commit time if a transaction is active. If a transaction is active and this flag is true, then the event notification will be sent only when the transaction is committed. If the transaction is rolled back, the event will not be signaled. If there is no active transaction or this flag is false, then the event notification will occur immediately.

Options (I)

Options, reserved for future use, pass the value 0 for this parameter.

EventData (I)

Optional string value to pass to the event.

See Also

sp_CreateEvent

sp_DropAllEvents

sp_DropEvent

sp_WaitForAnyEvent

sp_WaitForEvent

Example

CREATE TRIGGER [UpdateCustomer]

ON CUSTOMER

AFTER UPDATE

BEGIN

EXECUTE PROCEDURE sp_SignalEvent( ‘my_event’, false, 0 );

END;

Example

CREATE TRIGGER [UpdateCustomer]

ON CUSTOMER

AFTER UPDATE

BEGIN  

  // Pass the ROWID from the updated table to the event

  EXECUTE PROCEDURE sp_SignalEvent( ‘my_event’, false, 0, ::stmt.TrigRowID );

END;