Re: Question about inserts

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: mike <mike(at)redtux1(dot)uklinux(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question about inserts
Date: 2004-04-23 14:02:57
Message-ID: 20040423140257.GC6182@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Apr 23, 2004 at 11:36:51 +0100,
mike <mike(at)redtux1(dot)uklinux(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pascal Polleunus 2004-04-23 14:28:16 Synchronize unicode data using copy or pg_dump
Previous Message Bruno Wolff III 2004-04-23 13:56:58 Re: Question about inserts