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:
Tom Lane
2010-01-19 01:35:31 +00:00
parent 8ab27affea
commit 309cd7cf18
7 changed files with 131 additions and 61 deletions

View File

@ -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 $$