From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Can I use check-constraint to set null? |
Date: | 2010-08-16 18:43:48 |
Message-ID: | AANLkTika=pej2h-fDnEs=dw_rxyFh2pP6m+tN78b-kfR@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 16 August 2010 19:34, Andreas Kretschmer <akretschmer(at)spamfence(dot)net> wrote:
> Rikard Bosnjakovic <rikard(dot)bosnjakovic(at)gmail(dot)com> wrote:
>
>> (Postgres 8.4.2)
>>
>> CREATE TABLE test (foo numeric(8,2) CHECK (foo >= 0.0));
>>
>> ecdb=> insert into test values (-2.2);
>> ERROR: new row for relation "test" violates check constraint "test_foo_check"
>>
>> This is expected.
>>
>> However, is there a way to insert a null when this check fails,
>> instead of returning an error (and thus aborting the insert)? I'm
>> reading on http://www.postgresql.org/docs/current/static/ddl-constraints.html
>> but cannot find an answer to this question.
>
> I think, you should use a TRIGGER.
>
I don't think suicide's the answer. Oh, wait, I see...
--
Thom Brown
Registered Linux user: #516935
From | Date | Subject | |
---|---|---|---|
Next Message | Charles Holleran | 2010-08-17 18:09:44 | update a table from a temp table |
Previous Message | Andreas Kretschmer | 2010-08-16 18:34:36 | Re: Can I use check-constraint to set null? |