Re: Question about inserts - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Question about inserts
Date
Msg-id 20040423140257.GC6182@wolff.to
Whole thread Raw
In response to Question about inserts  (mike <mike@redtux1.uklinux.net>)
List pgsql-general
On Fri, Apr 23, 2004 at 11:36:51 +0100,
  mike <mike@redtux1.uklinux.net> wrote:
> Is it possible to to the following
>
> I have tables which are updated via webpage (perl) with fields of type
> int and date (all nullable). If the values are blank the entire insert
> fails, with a wrong type error.
>
> Is there any way to stop this behaviour so that the valid information is
> allowed,but the blank values get ignored.

Ignore? If you want blanks turned into NULLs, probably the best place to
do this is in the application. I can think of three ways to do this:

Use NULLIF to replace the specified input strings into NULLs, while
leaving other strings as is.

Have the appkication detect the strings that should be NULL and replace them
with NULL (which shouldn't be quoted unlike the normal string data).

Split off the two columns that can have null values into their own tables
and only enter records there when the input is nonblank. This is perhaps
the closest to "ignoring" blanks that you can do.

pgsql-general by date:

Previous
From: "Stijn Vanroye"
Date:
Subject: Re: Question about inserts
Next
From: "Bas Scheffers"
Date:
Subject: Re: Insert Or update