Re: Null vs. Empty String in Postgres 8.3.8

From: CaT <cat(at)zip(dot)com(dot)au>
To: "Wang, Mary Y" <mary(dot)y(dot)wang(at)boeing(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Null vs. Empty String in Postgres 8.3.8
Date: 2010-04-05 03:28:06
Message-ID: 20100405032806.GZ2657@zip.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Apr 04, 2010 at 08:03:13PM -0700, Wang, Mary Y wrote:
> I still don't get it. I do want a zero for the subversion_flags to be stored in the table. But it returned an error because it didn't like subversion_flags='' in the UPDATE SQL statement.
>
> subversion_flags | integer | not null default 0

Thde default will not apply because you attempted to input a value.
Unless I'm mistaken the provision of any value (erroneous or otherwise)
obviates the activation of the default value. There is an exception
to this and that is using the DEFAULT keyword (ie subversion_flags=DEFAULT).

Otherwise the only way it activates is if you leave subversion_flags out
totally.

If you want input data mangling then a TRIGGER may be the way to go.

--
"A search of his car uncovered pornography, a homemade sex aid, women's
stockings and a Jack Russell terrier."
- http://www.news.com.au/story/0%2C27574%2C24675808-421%2C00.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sreelatha G 2010-04-05 04:40:47 Re: Dynamic plpgsql help
Previous Message Peter Hunsberger 2010-04-05 03:26:48 Re: Null vs. Empty String in Postgres 8.3.8