SQL/MX Queuing and Publish/Subscribe Services
Introduction
HP NonStop SQL/MX Queuing and Publish/Subscribe Services—523734-002
1-6
Comparing Triggers and Publish/Subscribe
Comparing Triggers and Publish/Subscribe
SQL/MX Release 2.0 introduces triggers functionality. Both triggers and 
publish/subscribe services offer ways to make a passive database more active. To 
decide which feature to use (or whether to use both in the same application), 
determine the needs of the application.
Table 1-1 compares triggers and publish/subscribe. For information about creating or 
altering triggers, see the SQL/MX Reference Manual.
Table 1-1. Comparing Triggers and Publish/Subscribe (page 1 of 2)
Feature Triggers Publish/Subscribe
ANSI compliant? Yes. No.
Portable? Yes. No.
Action/timing The trigger action can occur 
before or after an event.
The subscriber always 
follows the publisher.
Supported on rows and 
statements
You can have row triggers and 
statement triggers.
The subscriber sees only 
each row.
Event mechanism INSERT, UPDATE, or DELETE. INSERT and UPDATE.
Image of a row Triggers can see the before 
and after image of each row.
The subscriber sees the 
after image of a row (and 
not necessarily all updates 
to a row).
Transition variables Trigger actions can change 
transition variables (change the 
column values of the row 
updated or inserted by the 
triggering event).
The subscriber has no 
access to the row until the 
publisher commits.
Trigger action Triggers support the SIGNAL 
statement, allowing an 
operation to be disallowed and 
the transaction to be rolled 
back.
Publish/subscribe can 
approximate this function 
by using application logic to 
undo the transaction.
Function Triggers are declarative. You 
can declare a trigger as part of 
a DDL statement. SQL/MX 
enforces the triggers, making 
them easy to manage.
Subscribers are procedural. 
You have to write a 
program to subscribe 
against a given table. You 
must also run (deploy and 
manage) the program.
Transaction behavior The trigger event and action 
occur in the same transaction
The publisher and 
subscriber use different 
transactions
Process usage Trigger actions are handled by 
the same process as the 
triggering event.
The publisher and 
subscriber use different 
processes.










