From: Tom Lane <tgl@sss.pgh.pa.us>
To: Graham Vickrage <graham@digitalplanit.com>
Cc: postgresql <pgsql-sql@postgresql.org>
Subject: Re: Null function parameters
Date: Tue, 22 Aug 2000 13:15:20 -0400
Message-ID: <9387.966964520@sss.pgh.pa.us> (raw)
In-Reply-To: <NDBBJABDILOPAOOMFJHOOEAKCEAA.graham@digitalplanit.com>
References: <NDBBJABDILOPAOOMFJHOOEAKCEAA.graham@digitalplanit.com>
"Graham Vickrage" <graham@digitalplanit.com> 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'.
Not sure what you think you meant by that, but a null is a null. If you
declared the table column as NOT NULL then Postgres is doing exactly
what it should. You may wish to code the insert along the lines of
INSERT INTO table VALUES (..., COALESCE($1, suitable-default), ...)
COALESCE is a handy notation for "value1 unless it's NULL, in which case
value2".
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, graham@digitalplanit.com
Subject: Re: Null function parameters
In-Reply-To: <9387.966964520@sss.pgh.pa.us>
References: <NDBBJABDILOPAOOMFJHOOEAKCEAA.graham@digitalplanit.com> <9387.966964520@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox