Skip site navigation (1) Skip section navigation (2)

Re: Null function parameters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Graham Vickrage" <graham(at)digitalplanit(dot)com>
Cc: "postgresql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Null function parameters
Date: 2000-08-22 17:15:20
Message-ID: 9387.966964520@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
"Graham Vickrage" <graham(at)digitalplanit(dot)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

In response to

Responses

pgsql-sql by date

Next:From: Tom LaneDate: 2000-08-22 18:16:20
Subject: Re: Continuous inserts...
Previous:From: Brian C. DoyleDate: 2000-08-22 16:26:35
Subject: Re: Time Help

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group