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

Re: Possible to insert quoted null value into integer field?

From: Jerry Sievers <jerry(at)jerrysievers(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Possible to insert quoted null value into integer field?
Date: 2004-08-24 12:23:14
Message-ID: m38yc4913h.fsf@prod01.jerrysievers.com (view raw or flat)
Thread:
Lists: pgsql-general
pablo_tweek(at)yahoo(dot)com (Pablo S) writes:

> Hi all, I have search high and low on this - 
> Take for instance the statement : 
> 
> insert into foo (text1, text2, int1) values ('Foo', 'Bar', '');

Have a look at nullif();

create table foo (a int)
;

insert into foo
values (nullif('$varWhichMayBeEmptyString', '')::int)
;

As I recall, there is a comment in the release notes somewhere between
your PG version and the current one, that int cols no longer take
empty string as NULL.

HTH

-- 
-------------------------------------------------------------------------------
Jerry Sievers   305 854-3001 (home)     WWW ECommerce Consultant
                305 321-1144 (mobile	http://www.JerrySievers.com/

In response to

Responses

pgsql-general by date

Next:From: Peter EisentrautDate: 2004-08-24 13:04:40
Subject: Re: select ... where <column>='' does a seqscan [auf Viren geprueft]
Previous:From: SecrétariatDate: 2004-08-24 11:53:38
Subject: Re: No connection to a PG 8.0 Beta 1 win32 server

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