Can I use DECODE in a UPDATE statement on the left hand side of SET?
UPDATE temp SET DECODE(update_var, 1, col1, 2, col2) = update_value;
This is giving me error as eual sign ignored..
How about this? If the update flag is set to 1, col1 gets updated, if set to 2, then col2 gets updated.
UPDATE temp
SET col1 = DECODE(update_var, 1, update_value, col1),
col2 = DECODE(update_var, 2, update_value, col2)
Also, as a bonus, it'll handle the possible situation where the update variable is set to something other than one or two!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With