From: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | Artacus <artacus(at)comcast(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: declare column update expression |
Date: | 2008-09-12 03:34:18 |
Message-ID: | dcc563d10809112034mb48d81h561b9d731e345cbf@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Sep 11, 2008 at 8:50 PM, Artacus <artacus(at)comcast(dot)net> wrote:
>
>> How is it that you can declare the default value of a column on insert
>> but not on update?
>
> You can do this without triggers (at least on 8.3).
>
> UPDATE foo
> SET field1 = 2,
> field2 = default
> WHERE field3 = 22
>
> I just tested it and it will set the value back to the default. The caveat
> here is that it won't FORCE the value like it would with a trigger. So while
> the trigger would happen automatically, using this approach, you'd have to
> remember to also update that field any time you did an update.
Right, but now you've moved the complexity of timestamping updates
into the application layer, where it has to be propagated to all
update queries. Miss one and it won't get updated.
i wonder if you could do it with a rule?
From | Date | Subject | |
---|---|---|---|
Next Message | Goboxe | 2008-09-12 03:34:54 | Trigger does not behave as expected |
Previous Message | Scott Marlowe | 2008-09-12 03:32:35 | Re: declare column update expression |