mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-09 00:57:47 +08:00
Support for MOVE in PL/PgSQL. Initial patch from Magnus, some improvements
by Pavel Stehule, and reviewed by Neil Conway.
This commit is contained in:
@ -2511,4 +2511,27 @@ $$ language plpgsql;
|
||||
|
||||
select * from sc_test();
|
||||
|
||||
create or replace function sc_test() returns setof integer as $$
|
||||
declare
|
||||
c cursor for select * from generate_series(1, 10);
|
||||
x integer;
|
||||
begin
|
||||
open c;
|
||||
loop
|
||||
move relative 2 in c;
|
||||
if not found then
|
||||
exit;
|
||||
end if;
|
||||
fetch next from c into x;
|
||||
if found then
|
||||
return next x;
|
||||
end if;
|
||||
end loop;
|
||||
close c;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select * from sc_test();
|
||||
|
||||
drop function sc_test();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user