NOTIFY
SQL - Language Statements
NOTIFY
Signals all frontends and backends listening on a class
1998-09-24
NOTIFY classname
1998-09-24
Inputs
classname
Table or arbitrary relation class used for notification.
1998-09-24
Outputs
status
NOTIFY
Notification message from backend.
1998-09-24
Description
NOTIFY is used to awaken all sessions which have
previously executed
LISTEN classname.
This can be used either within an instance-level rule
as part of the action body or from a normal query.
When used from within a normal query,
this can be thought of as interprocess communication (IPC). When
used from within a rule, this can be thought of as an alert mechanism.
Note that the mere fact that a NOTIFY has been
executed does not imply anything in particular about the state
of the class (e.g., that it has been updated),
nor does the notification protocol transmit any useful information
other than the class name.
Therefore, all NOTIFY does is indicate that some backend
wishes its peers to
examine classname
in some application-specific way.
In fact, classname
need not be the name of an SQL class at all.
It is best thought of as a condition name
that the application programmer selects.
This event notification is performed through the libpq protocol
and frontend application interface. The application program
must call the routine PQnotifies
in order to find out the name of the class to which a given
notification corresponds.
If this code is not included in the application,
the event notification will be
queued and never be processed.
1998-09-24
Notes
Usage
-- Configure and execute a listen/notify sequence
-- from psql
CREATE TABLE t (i int4);
LISTEN t;
NOTIFY t;
NOTIFY
ASYNC NOTIFY of 't' from backend pid '10949' received
Compatibility
1998-09-24
SQL92
There is no NOTIFY statement in SQL92.