Received: from tolikus.hq.aaanet.ru (tolikus.hq.aaanet.ru [213.59.98.206]) by hub.org (8.10.1/8.10.1) with ESMTP id e7NBlaT62419 for ; Wed, 23 Aug 2000 07:47:36 -0400 (EDT) Received: (from tolik@localhost) by tolikus.hq.aaanet.ru (8.9.3/8.9.3) id PAA06362; Wed, 23 Aug 2000 15:46:14 +0400 (MSD) (envelope-from tolik) To: Tom Lane Cc: "Graham Vickrage" , "postgresql" Subject: Re: Null function parameters References: <9387.966964520@sss.pgh.pa.us> Mime-Version: 1.0 (generated by tm-edit 1.5) Content-Type: text/plain; charset=US-ASCII From: tolik@aaanet.ru (Anatoly K. Lasareff) Date: 23 Aug 2000 15:46:14 +0400 In-Reply-To: Tom Lane's message of "Tue, 22 Aug 2000 13:15:20 -0400" Message-ID: <86ya1o8ak9.fsf@tolikus.hq.aaanet.ru> Lines: 54 X-Mailer: Gnus v5.6.45/XEmacs 21.1 - "Canyonlands" X-Archive-Number: 200008/238 >>>>> "TL" == Tom Lane writes: TL> "Graham Vickrage" writes: >> However my understanding was that if the default value is SQL NULL then any >> values passed into the function that are null would be treated as 'NULL'. TL> Not sure what you think you meant by that, but a null is a null. If you TL> declared the table column as NOT NULL then Postgres is doing exactly TL> what it should. You may wish to code the insert along the lines of TL> INSERT INTO table VALUES (..., COALESCE($1, suitable-default), ...) TL> COALESCE is a handy notation for "value1 unless it's NULL, in which case TL> value2". TL> regards, tom lane But unfortunately we have no answer for primary question: | Why if we pass to function ONLY ONE null agument all the oters | | argumenta in function's boby are null too? | | Or: is it possible to pass null arguments into plpgsql functions? | Example. create function a(int, int) returns int as ' begin raise notice ''1: % 2: %'', $1, $2; if $1 is null then return $2; end if; return $1; end; ' language 'plpgsql'; tolik=# select a(1,2); NOTICE: 1: 1 2: 2 a --- 1 (1 row) tolik=# select a(null,2); NOTICE: 1: 2: a --- (1 row) -- Anatoly K. Lasareff Email: tolik@aaanet.ru