mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-08 20:37:29 +08:00
Add "USING expressions" option to plpgsql's OPEN cursor FOR EXECUTE.
This is the last EXECUTE-like plpgsql statement that was missing the capability of inserting parameter values via USING. Pavel Stehule, reviewed by Itagaki Takahiro
This commit is contained in:
@ -2629,6 +2629,28 @@ $$ language plpgsql;
|
||||
|
||||
select exc_using(5, 'foobar');
|
||||
|
||||
drop function exc_using(int, text);
|
||||
|
||||
create or replace function exc_using(int) returns void as $$
|
||||
declare
|
||||
c refcursor;
|
||||
i int;
|
||||
begin
|
||||
open c for execute 'select * from generate_series(1,$1)' using $1+1;
|
||||
loop
|
||||
fetch c into i;
|
||||
exit when not found;
|
||||
raise notice '%', i;
|
||||
end loop;
|
||||
close c;
|
||||
return;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select exc_using(5);
|
||||
|
||||
drop function exc_using(int);
|
||||
|
||||
-- test FOR-over-cursor
|
||||
|
||||
create or replace function forc01() returns void as $$
|
||||
|
||||
Reference in New Issue
Block a user