1LISTEN(7) SQL Commands LISTEN(7)
2
3
4
6 LISTEN - listen for a notification
7
8
10 LISTEN name
11
12
14 LISTEN registers the current session as a listener on the notification
15 condition name. If the current session is already registered as a lis‐
16 tener for this notification condition, nothing is done.
17
18 Whenever the command NOTIFY name is invoked, either by this session or
19 another one connected to the same database, all the sessions currently
20 listening on that notification condition are notified, and each will in
21 turn notify its connected client application. See the discussion of
22 NOTIFY for more information.
23
24 A session can be unregistered for a given notify condition with the
25 UNLISTEN command. A session's listen registrations are automatically
26 cleared when the session ends.
27
28 The method a client application must use to detect notification events
29 depends on which PostgreSQL application programming interface it uses.
30 With the libpq library, the application issues LISTEN as an ordinary
31 SQL command, and then must periodically call the function PQnotifies to
32 find out whether any notification events have been received. Other
33 interfaces such as libpgtcl provide higher-level methods for handling
34 notify events; indeed, with libpgtcl the application programmer should
35 not even issue LISTEN or UNLISTEN directly. See the documentation for
36 the interface you are using for more details.
37
38 NOTIFY [notify(7)] contains a more extensive discussion of the use of
39 LISTEN and NOTIFY.
40
42 name Name of a notify condition (any identifier).
43
45 Configure and execute a listen/notify sequence from psql:
46
47 LISTEN virtual;
48 NOTIFY virtual;
49 Asynchronous notification "virtual" received from server process with PID 8448.
50
51
53 There is no LISTEN statement in the SQL standard.
54
56 NOTIFY [notify(7)], UNLISTEN [unlisten(7)]
57
58
59
60SQL - Language Statements 2014-02-17 LISTEN(7)