parametrized NOTIFY - issue in plpgsql, maybe ToDo

Started by Pavel Stehuleabout 16 years ago3 messageshackers
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com

Hello

I am testing NOTIFY statement. It have to be used from plpgsql via
EXECUTE, because doesn't support paramaters.

Can be it documented somewhere?

create or replace function foo(a varchar)
returns void as $$
begin
execute 'notify xxx, ' || quote_literal(a);
return;
end;
$$ language plpgsql;
CREATE FUNCTION
Time: 2,513 ms
pavel@postgres:5432=# select foo('pavel');
foo
-----

(1 row)

Time: 31,732 ms
pavel@postgres:5432=# listen xxx;
LISTEN
Time: 0,271 ms
pavel@postgres:5432=# select foo('pavel');
foo
-----

(1 row)

Time: 436,058 ms
Asynchronous notification "xxx" with payload "pavel" received from
server process with PID 4730.
pavel@postgres:5432=#

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Pavel Stehule (#1)
Re: parametrized NOTIFY - issue in plpgsql, maybe ToDo

Pavel Stehule <pavel.stehule@gmail.com> writes:

I am testing NOTIFY statement. It have to be used from plpgsql via
EXECUTE, because doesn't support paramaters.

Can be it documented somewhere?

It is. Use the function instead.

regards, tom lane

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tom Lane (#2)
Re: parametrized NOTIFY - issue in plpgsql, maybe ToDo

2010/3/16 Tom Lane <tgl@sss.pgh.pa.us>:

Pavel Stehule <pavel.stehule@gmail.com> writes:

I am testing NOTIFY statement. It have to be used from plpgsql via
EXECUTE, because doesn't support paramaters.

Can be it documented somewhere?

It is.  Use the function instead.

ok thank you for info

Pavel

Show quoted text

                       regards, tom lane