Can a PL/PgSQL function return a cursor?

From: Jeff Duffy <jeff(at)alanne(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Can a PL/PgSQL function return a cursor?
Date: 2001-01-14 08:01:40
Message-ID: 01011403014000.01201@cairhien
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I have not had any luck getting a PL/PgSQL function that returns a
cursor to compile. I've tried writing this in several forms, for
instance;

CREATE FUNCTION getcursor()
RETURNS cursor
AS
'BEGIN
DECLARE testcursor CURSOR FOR
SELECT * FROM test_table;
RETURN testcursor;
END;'
LANGUAGE 'plpgsql';

but the parser always complains:

ERROR: parser: parse error at or near "cursor"

I assume this means that cursor is not a valid return type for PL/PgSQL
functions? The point of this is to map queries that return large
results sets to cursors for use in Java (through the ResultSet type).

I'm using 7.0.3 on Red Hat 7.0.

Jeff

--
Errors have occurred.
We won't tell you where or why.
Lazy programmers.
-- Hacking haiku

Browse pgsql-general by date

  From Date Subject
Next Message Dan Langille 2001-01-14 10:19:40 getting number of rows updated within a procedure
Previous Message Muhammad Rusydi 2001-01-14 07:51:44 update field table.....