Re: Question about NOT NULL and default values.

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Question about NOT NULL and default values.
Date: 2008-10-17 15:42:06
Message-ID: 48F8B24E.5030904@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Marlowe wrote:
> On Thu, Oct 16, 2008 at 10:06 PM, Stephan Szabo
> <sszabo(at)megazone(dot)bigpanda(dot)com> wrote:
>> On Thu, 16 Oct 2008, Scott Marlowe wrote:
>>
>>> On Thu, Oct 16, 2008 at 10:01 PM, Stephan Szabo
>>> <sszabo(at)megazone(dot)bigpanda(dot)com> wrote:
>>>> On Fri, 17 Oct 2008, Tim Uckun wrote:
>>>>
>>>>> Is there a way to change this behavior so that an attempt to set the
>>>>> column to NULL will result in the default value being put in the
>>>>> field?
>>>> I don't think so specifically with default, but you could use a before
>>>> trigger instead that would put in a value in the new row if NULL was
>>>> given.
>>> I'm pretty sure that will fail as the primary key or not null
>>> constraint comes first.
>> Well, since he said that he'd removed the not null constraint in his
>> testing, I figured that was a viable option.
>
> Yeah, then it might. But I get the feeling the OP just wasn't
> assigning a sequence as a defult.
>

I don't think the OP wants this column to have a sequence. It looked to
me that he wants it to default to zero. I think the confusion was caused
by a comment about MySQL's autoincrement handling.

It seems to me that the problem lies with postgres-pr and the best thing
to do until that's fixed would be to use a trigger, as someone else
suggested.

b

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-10-17 15:43:06 Re: Drop database / database in use question
Previous Message Andrus 2008-10-17 15:32:09 Re: OR or IN ?