如何执行PERFORM pg_notify('', '')?

How to execute PERFORM pg_notify('', '')?

当我执行 PERFORM pg_notify('channel', 'payload'); 时,出现以下错误:

ERROR:  syntax error at or near "PERFORM"
LINE 1: PERFORM pg_notify('channel', 'payload');
        ^

我做错了什么?

SELECT 的对应项有效,但我正在寻找无结果的等效项。我正在使用 psql (9.5.3, server 9.5.0).

这里的问题在于PERFORM不能直接在提示中执行。正如 documentation 所说:

Sometimes it is useful to evaluate an expression or SELECT query but discard the result, for example when calling a function that has side-effects but no useful result value. To do this in PL/pgSQL, use the PERFORM statement:

这有点棘手,但 PERFORM 只能在 PL/pgSQL 上下文(函数、存储过程和其他东西)中使用。我试图在不支持的提示中直接执行它。