Re: Functions returning RECORD

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: Craig Bryden <postgreSQL(at)bryden(dot)co(dot)za>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Functions returning RECORD
Date: 2005-01-13 20:41:23
Message-ID: Pine.LNX.4.44.0501132138440.29441-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

try
select * from GetAccountInfo (100) as (integer, integer, integer);

I don't know types of fields a.Field1, a.Field2, a.Field4. I expect for
example all are integer.

regards
Pavel Stehule

On Thu, 13 Jan 2005, Craig Bryden wrote:

> Hi
>
> I come from a MS-SQL background and am trying to figure out what is wrong with the function below:
> *****************************************************************************************
> CREATE OR REPLACE FUNCTION GetAccountInfo (p_AccID int)
> RETURNS record
> AS
> $$
> DECLARE
> r_Return record;
> BEGIN
> SELECT a.Field1, a.Field2, a.Field4
> INTO r_Return
> FROM Account
> WHERE a.AccID = p_AccID;
>
> RETURN r_Return;
> END;
> $$
> language 'plpgsql';
> *****************************************************************************************
> When I run select * from GetAccountInfo (100) I get the following error message: ERROR: a column definition list is required for functions returning "record"
>
> please can someone explain to me how to create a column definition list.
>
>
> Thanks
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike G. 2005-01-13 20:44:30 Cursor bug?
Previous Message Michael Fuhr 2005-01-13 20:37:36 Re: Functions returning RECORD