From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Chris Velevitch" <chris(dot)velevitch(at)gmail(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Using case expressions in update set clause |
Date: | 2007-10-15 08:41:25 |
Message-ID: | 87sl4csrbe.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Chris Velevitch" <chris(dot)velevitch(at)gmail(dot)com> writes:
> I just want to clarify that the following will always behave the way I
> think it's supposed to behave:-
>
> update tableA
> set date_field = case when date_field is null then some_date
> else date_field end;
>
> If the current value of date_field for the current record is null then
> set the date_field with some_date value otherwise keep the current
> value of date_field.
That's correct. In this case you could also do it with
set date_field = coalesce(date_field, some_date)
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Stark | 2007-10-15 08:44:53 | Re: CHAR SETS |
Previous Message | Laurent ROCHE | 2007-10-15 08:31:50 | Re : Very asynchrnous replication system |