Re: returning rows from a function

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "Nikheel Dhekne" <ndhekne(at)netaid(dot)org>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: returning rows from a function
Date: 2002-02-20 23:37:41
Message-ID: 002401c1ba69$4aae64c0$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You can't return a result set as such from a function. But if you are using
7.2, you can now return a cursor to a result set:

http://www7.us.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql-cursors
.html

Greg

----- Original Message -----
From: Nikheel Dhekne
To: pgsql-general(at)postgresql(dot)org
Sent: Wednesday, February 20, 2002 6:01 PM
Subject: [GENERAL] returning rows from a function

I am new to Postgres and have a rather straightforward question. Is it
possible, and if so, what is the syntax for returning a recordset from a
function?

I have tried

CREATE FUNCTION selectUserProperties(text) RETURNS RECORD

and

CREATE FUNCTION selectUserProperties(text) RETURNS SETOF varchar

Neither of which seems to work. The rest of the function is.

CREATE FUNCTION selectUserProperties (text) RETURNS RECORD
AS '

BEGIN
SELECT key,
value
FROM user_properties
WHERE username = $1;

END;

' LANGUAGE 'plpgsql';

Both key and value in this example are varchar columns.

Thanks for your help.

__________________
Nikheel Dhekne
NetAid | Developer
http://www.netaid.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hugo Coolens 2002-02-20 23:54:56 entering empty value
Previous Message Tom Lane 2002-02-20 23:18:13 Re: [GENERAL] schema error upgrading from 7.1 to 7.2