Re: functions are returns columns - Mailing list pgsql-sql

From Michele Petrazzo - Unipex srl
Subject Re: functions are returns columns
Date
Msg-id 4735EC6F.5050908@unipex.it
Whole thread Raw
In response to Re: functions are returns columns  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Responses Re: functions are returns columns  (Gregory Stark <stark@enterprisedb.com>)
List 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


pgsql-sql by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: functions are returns columns
Next
From: Gregory Stark
Date:
Subject: Re: functions are returns columns