Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsqVk-0005Cy-0T for pgsql-admin@arkaria.postgresql.org; Thu, 23 Aug 2018 14:22:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsqVh-0000VB-FL for pgsql-admin@arkaria.postgresql.org; Thu, 23 Aug 2018 14:22:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsqVh-0000Ux-4C for pgsql-admin@lists.postgresql.org; Thu, 23 Aug 2018 14:22:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsqVd-0001aa-PT for pgsql-admin@postgresql.org; Thu, 23 Aug 2018 14:22:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7NEMWhW016791; Thu, 23 Aug 2018 10:22:32 -0400 From: Tom Lane To: Stefan Zauchenberger cc: pgsql-admin@postgresql.org Subject: Re: Call Function from within Function - parent / dispatch In-reply-to: <7B1A245D-F8DD-4AAB-8ACF-3C2C7F5A9563@ice-sys.com> References: <7B1A245D-F8DD-4AAB-8ACF-3C2C7F5A9563@ice-sys.com> Comments: In-reply-to Stefan Zauchenberger message dated "Thu, 23 Aug 2018 08:52:17 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16789.1535034152.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 23 Aug 2018 10:22:32 -0400 Message-ID: <16790.1535034152@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Stefan Zauchenberger writes: > I am having a problem creating a parent function that calls different fu= nctions within based on conditions. The functions within all take the exac= t same arguments and return the same set type. This must be a simple mista= ke on my part, but not sure of the fix. If you're trying to pass a set result back up, the easiest way is to use "RETURN QUERY SELECT * FROM child_function(...)". Plain "RETURN" only works for scalar results, and RETURN NEXT is for producing a result-set one row at a time. regards, tom lane