Returning a reference to a cursor from a function - Mailing list pgsql-sql

From david williams
Subject Returning a reference to a cursor from a function
Date
Msg-id DAV374EsURKQaJcrJf00000cd8c@hotmail.com
Whole thread Raw
Responses Re: Returning a reference to a cursor from a function
List pgsql-sql
To anyone who can help me,
 
I am new at Postgresql and am having some problems.
 
I am trying to return a rowset from a function to the calling procedure.
 
Outside a function I have gotten this to work at the psql level.
 
-------------
BEGIN Work;
    DECLARE Liahona CURSOR FOR Select * from users;
FETCH FORWARD ALL IN Liahona;
CLOSE Liahona;
COMMIT Work;
--------------
 
I went a stage further attempt to put this query into a function as such
 
--------------
CREATE FUNCTION getallusers() RETURN integer AS'
DECLARE
    Liahona CURSOR FOR Select * from users;
BEGIN
 
FETCH FORWARD ALL IN Liahona;
 
CLOSE Liahona;
END;
'language 'plpgsql';
 
---------------
Followed by 'select getallusers();' for testing purposes.
 
I get the error:
 
ERROR during compile of getallusers near line 5
Parse error at or near "FORWARD"
 
I have tried creating RECORD type cursors but no luck.
 
Can anyone suggest how to do this.
 
I was referenced to this this through my discussion at dbforums.com.
 
Thanks

!-------------------------------------!
David Williams


Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com

pgsql-sql by date:

Previous
From: Hanno Wiegard
Date:
Subject: Table alias in DELETE statements
Next
From: James Orr
Date:
Subject: Re: Latitude / Longitude