Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 7A4FC9F99B7 for ; Sat, 10 Nov 2007 13:38:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 44350-02 for ; Sat, 10 Nov 2007 13:37:53 -0400 (AST) Received: from relay0.fra.interoute.net (relay0.fra.interoute.net [212.23.33.89]) by postgresql.org (Postfix) with ESMTP id 15BBA9F9A02 for ; Sat, 10 Nov 2007 13:37:53 -0400 (AST) Received: from debian-srv (unknown [89.202.235.9]) by relay0.fra.interoute.net (Postfix) with ESMTP id 52A1AC322 for ; Sat, 10 Nov 2007 17:37:52 +0000 (UTC) Received: from [192.168.1.103] (michele [192.168.1.103]) by debian-srv (Postfix) with ESMTP id 03D0770228 for ; Sat, 10 Nov 2007 18:37:54 +0100 (CET) Message-ID: <4735EC6F.5050908@unipex.it> Date: Sat, 10 Nov 2007 18:37:51 +0100 From: Michele Petrazzo - Unipex srl User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b1) Gecko/20060724 Thunderbird/2.0a1 Mnenhy/0.7.4.0 MIME-Version: 1.0 To: Pgsql-Sql Subject: Re: functions are returns columns References: <4734B921.5050704@unipex.it> <162867790711091235i7e77abcch27731d91285949b6@mail.gmail.com> In-Reply-To: <162867790711091235i7e77abcch27731d91285949b6@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/38 X-Sequence-Number: 29566 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