From: david williams <dw_remote@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: Returning a reference to a cursor from a function
Date: Thu, 12 Sep 2002 14:12:37 -0400
Message-ID: <DAV374EsURKQaJcrJf00000cd8c@hotmail.com> (raw)
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.
http://dbforums.com/t499825.html
Thanks
!-------------------------------------!
David WilliamsGet more from the Web. FREE MSN Explorer download : http://explorer.msn.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dw_remote@hotmail.com
Subject: Re: Returning a reference to a cursor from a function
In-Reply-To: <DAV374EsURKQaJcrJf00000cd8c@hotmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox