Bug #945: RFE: Update table SET CASE...END=foo WHERE... - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Bug #945: RFE: Update table SET CASE...END=foo WHERE...
Date
Msg-id 20030413011804.43BCB476351@postgresql.org
Whole thread Raw
List pgsql-bugs
Richard Neill (postgresql@richardneill.org) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
RFE: Update table SET CASE...END=foo WHERE...

Long Description
It would be *really* nice to be able to determine the column which should be updated by a case statement. Eg:

UPDATE tbl_foo SET
CASE WHEN column1='bar' THEN column3 WHEN column2='baz' THEN column4 END
='wibble' WHERE column5='flibble';

i.e. depending on the values of column1/column2, the value wibble is assigned to column3 or column4

If this isn't possible, may I at least suggest a note in the manual to this effect, and with the workaround.

[Another thing to add to the manual in 6.12 is that a CASE statement inside a SELECT may be used to determine which
column'scontents to  
return]

I'm using version 7.2.2

Sample Code
UPDATE tbl_messages set CASE WHEN idto=8 THEN recipientread WHEN idfrom=8 THEN senderread END ='true' WHERE id=1910787;

This is the SQL I actually want to execute...and can't. Thanks for your help.

No file was uploaded with this report

pgsql-bugs by date:

Previous
From: "Robert Creager"
Date:
Subject: Re: heap_mark4update: (am)invalid tid
Next
From: "Luna Kid"
Date:
Subject: PANIC: read of clog file 0, offset 16384 failed: Success