Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 169502E023B for ; Thu, 14 Feb 2008 09:50:48 -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 52084-03 for ; Thu, 14 Feb 2008 09:50:26 -0400 (AST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 103782E023A for ; Thu, 14 Feb 2008 09:50:33 -0400 (AST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JPeTu-0007La-50 for pgsql-sql@postgresql.org; Thu, 14 Feb 2008 13:50:30 +0000 Received: from pirus.securax.be ([213.16.46.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Feb 2008 13:50:30 +0000 Received: from milen by pirus.securax.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Feb 2008 13:50:30 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Milen A. Radev" Subject: Re: PL/pgSQL question Date: Thu, 14 Feb 2008 15:50:13 +0200 Lines: 27 Message-ID: References: <99b656cb0802140523o165f69ebtcb4a42307c085f18@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pirus.securax.be User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <99b656cb0802140523o165f69ebtcb4a42307c085f18@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/106 X-Sequence-Number: 30197 Sebastian Ritter написа: > Hi all, > > I have a question regarding functions. How can I return zero rows from a > function whose return type is a table row? I did the following test and it > did not work as expected: [...] CREATE OR REPLACE FUNCTION foobar(boolean) RETURNS SETOF x AS $_$ DECLARE res x%ROWTYPE; BEGIN if $1 THEN RETURN NEXT res; ELSE RETURN; END IF; END;$_$ LANGUAGE plpgsql; -- Milen A. Radev