returning setof in plpgsql

From: "David Durst" <ddurst(at)larubber(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: returning setof in plpgsql
Date: 2003-01-21 10:40:02
Message-ID: 52900.216.86.192.34.1043145602.squirrel@www.la-rubber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a function that I want to return setof a table in plpgsql.

Here is what I have:

CREATE FUNCTION lookup_account(varchar(32)) RETURNS SETOF accounts AS '
DECLARE
aname ALIAS FOR $1;
rec RECORD;
BEGIN
select into rec * from accounts where accountname = aname;
return rec;
END;'
LANGUAGE 'plpgsql';

This seems to hang when I attempt to select it using:

select accountid(
lookup_account('some account')),
accountname(lookup_account('some account')),
type(lookup_account('some account')),
balance(lookup_account('some account'));

Does anyone see a problem w/ my approach??

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Raúl Gutiérrez Sánchez 2003-01-21 11:52:07 Speed depending of Join Order.
Previous Message Vernon Wu 2003-01-21 05:32:25 Re: performance question