Обсуждение: Re: Possible to insert quoted null value into integer field?

Поиск
Список
Период
Сортировка

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

От
Jerry Sievers
Дата:
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?

От
Martijn van Oosterhout
Дата:
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.

Вложения