Re: BUG #14184: Function is running correct but not showing output

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: zubair alam <zzia88(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgreSQL(dot)org
Subject: Re: BUG #14184: Function is running correct but not showing output
Date: 2016-06-13 15:25:24
Message-ID: 17998.1465831524@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

zubair alam <zzia88(at)gmail(dot)com> 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-06-13 15:51:11 Re: BUG #14185: Indentation error in win32.mak let libpq compile fail on USE_OPENSSL=1 -- fix available
Previous Message Tom Lane 2016-06-13 15:05:57 Re: BUG #14184: Function is running correct but not showing output