Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 495
Mehran Avatar asked Jan 29 '26 15:01

Mehran


1 Answers

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.

like image 76
Mehran Avatar answered Jan 31 '26 06:01

Mehran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!