LISTEN 中文man页面

系统
LISTEN 将当前会话注册为通知条件 name

NAME

LISTEN - 监听一个通知

SYNOPSIS

LISTEN name

DESCRIPTION 描述

LISTEN 将当前会话注册为通知条件 name


 当执行了命令 NOTIFY name  后,不管是此会话还是其他联接到同一数据库的会话执行的, 所有正在监听此通知条件的会话都将收到通知, 并且接下来每个会话将通知与其相连的前端应用.请参考 NOTIFY  获取更多信息.


 使用 UNLISTEN 命令,可以将一个会话内已注册的通知条件删除. 同样,会话退出时自动删除该会话正在监听的已注册通知条件.


 前端应用检测通知事件的方法取决于 PostgreSQL 应用使用的编程接口. 如果使用基本的libpq库, 应用将 LISTEN 当作普通 SQL 命令使用,而且必须周期地调用 PQnotifies 过程来检测是否有通知到达. 其他像libpgtcl接口提供了更高级的控制通知事件的方法;实际上, 使用libpgtcl,应用程序员不应该直接使用 LISTEN 或 UNLISTEN. 请参考你使用的接口的文档获取更多细节.

NOTIFY [notify(7)] 的手册页包含更广泛的关于 LISTEN 和 NOTIFY 的使用的讨论.  

PARAMETERS 参数

name

 通知条件名 (任何标识符)。

EXAMPLES 例子


 在 psql 里配制和执行一个监听/通知序列:

LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.

COMPATIBILITY 兼容性


 在 SQL 标准里没有 LISTEN  

SEE ALSO 参见

NOTIFY [notify(7)], UNLISTEN [unlisten(l)]

#p#

NAME

LISTEN - listen for a notification

SYNOPSIS

LISTEN name

DESCRIPTION

LISTEN registers the current session as a listener on the notification condition name. If the current session is already registered as a listener for this notification condition, nothing is done.

Whenever the command NOTIFY name is invoked, either by this session or another one connected to the same database, all the sessions currently listening on that notification condition are notified, and each will in turn notify its connected client application. See the discussion of NOTIFY for more information.

A session can be unregistered for a given notify condition with the UNLISTEN command. A session's listen registrations are automatically cleared when the session ends.

The method a client application must use to detect notification events depends on which PostgreSQL application programming interface it uses. With the libpq library, the application issues LISTEN as an ordinary SQL command, and then must periodically call the function PQnotifies to find out whether any notification events have been received. Other interfaces such as libpgtcl provide higher-level methods for handling notify events; indeed, with libpgtcl the application programmer should not even issue LISTEN or UNLISTEN directly. See the documentation for the interface you are using for more details.

NOTIFY [notify(7)] contains a more extensive discussion of the use of LISTEN and NOTIFY.  

PARAMETERS

name
Name of a notify condition (any identifier).

EXAMPLES

Configure and execute a listen/notify sequence from psql:

LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.

COMPATIBILITY

There is no LISTEN statement in the SQL standard.  

SEE ALSO

NOTIFY [notify(7)], UNLISTEN [unlisten(l)]

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-25 14:16:51

listen中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-25 09:07:16

suffixes中文man

2011-08-18 15:21:37

autofs中文man

2011-08-25 15:19:39

dirname中文man

2011-08-25 17:34:50

setlinebuf中文man

2011-08-15 15:17:14

ac中文man

2011-08-16 10:14:51

sndconfig中文man

2011-08-25 15:39:42

fcloseall中文man

2011-09-14 17:34:56

su中文man

2011-08-24 10:18:28

charsets中文man

2011-08-25 18:46:30

vprintf中文man

2011-08-15 18:32:09

paste中文man

2011-08-23 16:52:20

swapoff中文man

2011-08-25 16:50:08

getc中文man

2011-08-12 14:10:47

install中文man

2011-08-15 11:20:01

nice中文man
点赞
收藏

51CTO技术栈公众号