cursors in plpgsql

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Lista dyskusyjna pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: cursors in plpgsql
Date: 2003-09-17 20:46:08
Message-ID: 3F68C810.6020401@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi
I wanted to use some select result several times in pl/pgsql function.

DECLARE
test refcursor;
x record;
BEGIN
open test for select...
fetch test into x;
while found loop
...work...
fetch test into x;
end loop;

...rewind cursor using move...
fetch test...

Neither move backward 10000 in test;
nor
execute ''move backward 10000 in test'';
doesn't work.

In first case I get:
ERROR: parser: parse error at or near "$1"...
In secod:
ERROR: unexpected error -5 in EXECUTE of query...
I tried also with "perform" - I got no error, but also no valid result.

What should I do with it?
Or maybe is it possible somehow to use cursor in FOR..IN loop?

Regards,
Tomasz Myrta

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-09-17 21:13:13 Re: cursors in plpgsql
Previous Message Tomasz Myrta 2003-09-17 20:24:34 Re: how to get decimal to date form