Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 24D0D9F925E for ; Sat, 10 Nov 2007 15:36:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 78939-02 for ; Sat, 10 Nov 2007 15:36:05 -0400 (AST) Received: from oxford.xeocode.com (unknown [87.127.95.196]) by postgresql.org (Postfix) with ESMTP id EDF139F9509 for ; Sat, 10 Nov 2007 15:36:12 -0400 (AST) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1Iqw7l-00087B-W0; Sat, 10 Nov 2007 19:36:10 +0000 To: "Michele Petrazzo - Unipex srl" Cc: "Pgsql-Sql" Subject: Re: functions are returns columns In-Reply-To: <4735EC6F.5050908@unipex.it> (Michele Petrazzo's message of "Sat\, 10 Nov 2007 18\:37\:51 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.sql" 1309) References: <4734B921.5050704@unipex.it> <162867790711091235i7e77abcch27731d91285949b6@mail.gmail.com> <4735EC6F.5050908@unipex.it> From: Gregory Stark Organization: EnterpriseDB Date: Sat, 10 Nov 2007 19:36:09 +0000 Message-ID: <878x55dhau.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/39 X-Sequence-Number: 29567 "Michele Petrazzo - Unipex srl" writes: > 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... You're almost there: CREATE FUNCTION getfoo (IN int, OUT int, OUT int) returns setof record(int,int) AS $$ SELECT fooid, foosubid FROM foo WHERE fooid = $1; $$ LANGUAGE SQL; The return type if present has to match the OUT (and BOTH) parameters. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!