cursors in plpgsql - Mailing list pgsql-sql

From Tomasz Myrta
Subject cursors in plpgsql
Date
Msg-id 3F68C810.6020401@klaster.net
Whole thread Raw
Responses Re: cursors in plpgsql
List 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



pgsql-sql by date:

Previous
From: Tomasz Myrta
Date:
Subject: Re: how to get decimal to date form
Next
From: Tom Lane
Date:
Subject: Re: cursors in plpgsql