Re: functions are returns columns

From: Michele Petrazzo - Unipex srl <michele(dot)petrazzo(at)unipex(dot)it>
To: Pgsql-Sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: functions are returns columns
Date: 2007-11-10 17:37:51
Message-ID: 4735EC6F.5050908@unipex.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Pavel Stehule wrote:
>
> CREATE FUNCTION getfoo(int) RETURNS foo AS $$ SELECT fooid, foosubid
> FROM foo WHERE fooid = $1 LIMIT 1; $$ LANGUAGE SQL;
>

this return only one value, I need all the values that return the query

> or
>
> CREATE FUNCTION getfoo(int) RETURNS SETOF foo AS $$ SELECT fooid,
> foosubid FROM foo WHERE fooid = $1; $$ LANGUAGE SQL;
>

this create the same error:
ERROR: return type mismatch in function declared to return foo
DETAIL: Final SELECT returns too few columns.
CONTEXT: SQL function "getfoo

I try with:
CREATE FUNCTION getfoo (IN int, OUT int, OUT int) AS $$
SELECT fooid, foosubid FROM foo WHERE fooid = $1;
$$ LANGUAGE SQL;

but only one row returned...

Looking for other tips!

Thanks,
Michele

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-11-10 19:20:15 Re: High Availability, Load Balancing, and Replication Feature Matrix
Previous Message Tom Lane 2007-11-10 17:01:50 Re: sqlstate 22P06 is a warning in an error's clothing

Browse pgsql-sql by date

  From Date Subject
Next Message Gregory Stark 2007-11-10 19:36:09 Re: functions are returns columns
Previous Message Pavel Stehule 2007-11-09 20:35:20 Re: functions are returns columns