From: | Michele Petrazzo - Unipex srl <michele(dot)petrazzo(at)unipex(dot)it> |
---|---|
To: | Pgsql-Sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | functions are returns columns |
Date: | 2007-11-09 19:46:41 |
Message-ID: | 4734B921.5050704@unipex.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
Hi all.
I want that a function return a table rows (like the doc says at 33.4.4.
SQL Functions as Table Sources), but I want the a function return only a
few cols, so the same that I select into the func.
Modifying the doc example:
CREATE TABLE foo (fooid int, foosubid int, fooname text);
INSERT INTO foo VALUES (1, 1, 'Joe');
INSERT INTO foo VALUES (1, 2, 'Ed');
INSERT INTO foo VALUES (2, 1, 'Mary');
CREATE FUNCTION getfoo(int) RETURNS foo AS $$
SELECT fooid, foosubid FROM foo WHERE fooid = $1;
$$ LANGUAGE SQL;
This give me an error:
ERROR: return type mismatch in function declared to return foo
DETAIL: Final SELECT returns too few columns.
CONTEXT: SQL function "getfoo"
So, how do it?
Thanks,
Michele
From | Date | Subject | |
---|---|---|---|
Next Message | Doug Knight | 2007-11-09 20:04:01 | plperl.dll error from create langauge plperl (XP Pro 64 bit) |
Previous Message | Tom Lane | 2007-11-09 18:53:53 | Re: fulltext parser strange behave |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2007-11-09 20:35:20 | Re: functions are returns columns |
Previous Message | Alvaro Herrera | 2007-11-09 18:35:59 | Re: Select in From clause |