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

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

From
Jerry Sievers
Date:
pablo_tweek@yahoo.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/

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

From
Martijn van Oosterhout
Date:
On Tue, Aug 24, 2004 at 08:23:14AM -0400, Jerry Sievers wrote:
> 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.

IIRC, an empty string was interpreted as a zero, never as a NULL.
It is now (rightfully) rejected...
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment