Re: PL/pgsql return resultset/cursor?

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: Richard Emberson <emberson(at)phc(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/pgsql return resultset/cursor?
Date: 2002-03-23 10:54:11
Message-ID: 200203231054.g2NAsB217580@saturn.janwieck.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Emberson wrote:
>
> Is it possible to return a result-set or cursor from a PL/pgsql
> procedure, like
>
> CREATE OR REPLACE FUNCTION foo()
> RETURNS <WHAT_TYPE> AS '
> BEGIN
> RETURN SELECT * from FOO;
> END;
> ' LANGUAGE 'plpgsql';
>
> If you open a cursor in a procedure, it gets closed when the procedure
> exits, right?

Cursors get closed in PostgreSQL when you close them or when
the transaction ends.

Look at the refcursor data type (new in v7.2) and use
transactions.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 2002-03-23 13:32:16 Re: SQL Server performing much better?!?!
Previous Message Mark kirkwood 2002-03-23 06:24:24 Re: SQL Server performing much better?!?!