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

Re: Question about inserts

From: jseymour(at)LinxNet(dot)com (Jim Seymour)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Question about inserts
Date: 2004-04-23 23:39:12
Message-ID: 20040423233912.856884307@jimsun.LinxNet.com (view raw or flat)
Thread:
Lists: pgsql-general
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. 

You're not giving much information here.  What do you mean by "blank
field?"  That is to say: If the field (on the web form) is left blank,
what is your CGI script trying to do?

> 
> Is there any way to stop this behaviour so that the valid information is
> allowed,but the blank values get ignored. 

One way would be not try to set table fields to invalid values ;).

Look into using placeholders in your prepared statements and
conditionally binding them to NULL if a web form field has been left
blank by the user.

-- 
Jim Seymour                | Spammers sue anti-spammers:
jseymour(at)LinxNet(dot)com       |     http://www.LinxNet.com/misc/spam/slapp.php
http://jimsun.LinxNet.com  | Please donate to the SpamCon Legal Fund:
                           |     http://www.spamcon.org/legalfund/

In response to

pgsql-general by date

Next:From: Bruce MomjianDate: 2004-04-23 23:59:41
Subject: Re: thread_test.c problems
Previous:From: Igor ShevchenkoDate: 2004-04-23 22:40:55
Subject: Re: Insert Or update

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