NULL values in PL/pgSQL functions input

From: "Alex Bolenok" <abolen(at)pisem(dot)net>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: NULL values in PL/pgSQL functions input
Date: 2000-08-04 07:46:53
Message-ID: 000901bffde8$284984d0$df02a8c0@artey.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I wrote a function in PL/pgSQL that can accept NULL input values in some
variables. But I found that if I pass a single NULL value to the function,
all other values become NULL too. Here is the example:

CREATE FUNCTION fn_test(INT4, NUMERIC)
RETURNS NUMERIC AS '
BEGIN
RAISE NOTICE
''%, %'', $1, $2;
RETURN $2;
END;
' LANGUAGE 'plpgsql';

peroon#= SELECT fn_test(1, 2.00);
NOTICE: 1, 2.000000
fn_test
---------
2
(1 row)
peroon#= SELECT fn_test(1, NULL);
NOTICE: <NULL>, <NULL>
fn_test
---------

(1 row)

Is it a bug?

I found no notice about it in documentation, so one more question:

Is there any workaround?

Alex Bolenok.

Browse pgsql-general by date

  From Date Subject
Next Message Philip Warner 2000-08-04 09:35:40 Strange strategy with COALESCE?
Previous Message Peter Mount 2000-08-04 06:55:52 RE: [HACKERS] pg_dump/restore to convert BLOBs to LZTEXT (optiona l!)