Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCTk1-0007Ky-5c for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 15:25:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCTk0-0008Tc-OE for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 15:25:28 +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.84_2) (envelope-from ) id 1bCTk0-0008TW-CF for pgsql-bugs@postgreSQL.org; Mon, 13 Jun 2016 15:25:28 +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.84_2) (envelope-from ) id 1bCTjx-00047j-WC for pgsql-bugs@postgreSQL.org; Mon, 13 Jun 2016 15:25:27 +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 u5DFPOqZ017999; Mon, 13 Jun 2016 11:25:24 -0400 From: Tom Lane To: zubair alam cc: pgsql-bugs@postgreSQL.org Subject: Re: BUG #14184: Function is running correct but not showing output In-reply-to: References: <20160613134025.5792.79374@wrigleys.postgresql.org> <17297.1465830357@sss.pgh.pa.us> Comments: In-reply-to zubair alam message dated "Mon, 13 Jun 2016 18:14:57 +0300" Date: Mon, 13 Jun 2016 11:25:24 -0400 Message-ID: <17998.1465831524@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org zubair alam writes: > CREATE OR REPLACE FUNCTION FACTORIAL(IN NUM BIGINT,OUT FACT BIGINT) AS $$ > DECLARE > FACT BIGINT:=1; > BEGIN > FOR I IN REVERSE 1..NUM LOOP > FACT:=FACT*I; > END LOOP; > END; > $$ LANGUAGE plpgsql; > if i am doing FACT BIGINT:=1; the also it giving the output NULL; Well, the *third* bug in your function is that you're re-declaring FACT as a local variable, thereby masking the output parameter. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs