NULL value in one argument will clear all arguments in server-side functions ( plpgsql ) to NULL?!

From: "Serg King" <sergeiko(at)bdsn(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: NULL value in one argument will clear all arguments in server-side functions ( plpgsql ) to NULL?!
Date: 2000-10-02 20:08:06
Message-ID: GW5C5.8452$TP6.83052@newsread2.prod.itd.earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,
I'm using Postgres for the first time and have this problem:
when I use NULL as the value of one of the parameters in my stored
procedure, all the values of all the parameters in body of procedure will
cleared to NULL too.
(I have Postgres 7.0.2 on Linux RedHat 6.2 )

The simple example:

create function test(int4, char(10), date) returns int4 as '
BEGIN
INSERT INTO testtable VALUES ($1, $2, $3);
return 0; /* only for possibility to use SELECT for this function calls */
END;
' language 'plpgsql';

Try to use a NULL value when calling this function and you will see NULL
values for all fields in the table:

>SELECT test(1,'test', 'now'); - it works OK
>SELECT test(1, NULL, 'now'); - and it has trouble:
- after that see in testtable
>SELECT * from testtable
- and result is:
+----+------+-----------+
| t1 | t2 | t3 |
+----+------+-----------+
| 1 | test | 10/2/00 | - it's OK
| | | | - but here all values are NULL!
+----+------+-----------+
Query OK, 4 rows in set

My question is:
Is it a bug in PG? Is there any solution?
It is very important because I need to use NULL values.
Thanks a lot before,
Serge

Browse pgsql-general by date

  From Date Subject
Next Message Roderick A. Anderson 2000-10-02 21:05:46 Fake table name?
Previous Message KMiller 2000-10-02 19:46:52