Mehran
Mehran

Reputation: 16821

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

When I execute PERFORM pg_notify('channel', 'payload'); I get the following error:

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

What am I doing wrong?

The SELECT counterpart works, but I'm looking for a no-result equivalent. And I'm using psql (9.5.3, server 9.5.0).

Upvotes: 3

Views: 1948

Answers (1)

Mehran
Mehran

Reputation: 16821

The problem here relies on the fact that PERFORM can not be executed directly within the prompt. As the documentation says:

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:

It's a little bit tricky but PERFORM can only be used in a PL/pgSQL context (functions, stored procedures and stuff). And I was trying to execute it directly in the prompt which is not supported.

Upvotes: 4

Related Questions