MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » May 2014

RE: can sql CASE handle multiple column updates in a CASE statement?



fixed

I tried something like that and got the following error.

Keyword CASE not expected. Valid tokens: SET.

Looks you'll have to do something like

update jstone/docs00
set KEYWORD5 = case doctype2
when 'HEDGECONFIRMS' then KEYWORD1
when 'CONTRACTFORM' then xxx
etc.
end,
KEYWORD9 = case doctype2
when 'HEDGECONFIRMS' then KEYWORD2
when 'CONTRACTFORM' then xxx
etc.
end,
etc.

Caveat: I was using an old V5R4 system. Newer versions may have better
capability.

Have fun!

Richard

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
Stone, Joel
Sent: Thursday, May 08, 2014 12:25 PM
To: Midrange Systems Technical Discussion
Subject: can sql CASE handle multiple column updates in a CASE statement?

update jstone/docs00
case doctype2
when 'HEDGECONFIRMS'
set KEYWORD5 = KEYWORD1,
KEYWORD9 = KEYWORD2,
KEYWORD8 = KEYWORD3,
KEYWORD1 = ' ',
KEYWORD2 = ' ',
KEYWORD3 = ' '
when 'CONTRACTFORM'
when 'AMENDMENTFORM'




Or must I use many CASE statements to do this?

Thanks!

______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs
Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact