Re: declare column update expression

From: Artacus <artacus(at)comcast(dot)net>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: declare column update expression
Date: 2008-09-12 02:50:48
Message-ID: 48C9D908.7090007@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> 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.

Artacus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Velevitch 2008-09-12 03:06:22 Re: declare column update expression
Previous Message Gauthier, Dave 2008-09-12 02:09:55 Re: connection timeouts and "killing" users