Question on Cursor - Mailing list pgsql-novice

From Anusha Srinivasan
Subject Question on Cursor
Date
Msg-id 20050920133652.57032.qmail@web8506.mail.in.yahoo.com
Whole thread Raw
List pgsql-novice
Hi ,

I want to fetch 1000 records at a time from a
relation. Iam using CURSOR for this purpose . I tried
with the following approach, the problem with this is
the first row is stored in temp , but Iam not sure how
to retrieve the info back from that. The following
FETCH ALL leaves the entry which went into temp.
I want to store 1000 records at a time and want to
print it back . Can anybody guide me in this .

drop function reffunc(refcursor);

CREATE FUNCTION reffunc(refcursor) RETURNS refcursor
AS '
declare
        temp varchar(2);
BEGIN
        OPEN $1 FOR SELECT * FROM emp;
        fetch $1 into temp;
        RETURN $1;
END;
' LANGUAGE 'plpgsql';

BEGIN;
SELECT reffunc('funccursor');
FETCH ALL IN funccursor;
COMMIT;

Thanks and Regards
Anusha




___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
http://uk.security.yahoo.com

pgsql-novice by date:

Previous
From: Mike
Date:
Subject: Re: Starting PGSQL
Next
From: John DeSoi
Date:
Subject: Re: Starting PGSQL