Can a PL/PgSQL function return a cursor? - Mailing list pgsql-general

From Jeff Duffy
Subject Can a PL/PgSQL function return a cursor?
Date
Msg-id 01011403014000.01201@cairhien
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: "Muhammad Rusydi"
Date:
Subject: update field table.....
Next
From: "Dan Langille"
Date:
Subject: getting number of rows updated within a procedure