You cannot use decoding in update instructions. However, you can use the merge operator.
http://psoug.org/reference/merge.html
MERGE INTO temp b USING ( SELECT key, DECODE(update_var, 1, update_value, col1) as col1, DECODE(update_var, 2, update_value, col2) as col2 FROM temp WHERE key =theKeyIPassedIn) e ON (b.key = e.key) WHEN MATCHED THEN UPDATE SET b.col1 = e.col1, b.col2 = e.col2 ;
Basically you use the merge selection part to decode col1 and col2 either update_value or an existing value.
This may be too verbose for your needs, and a solution that uses an if statement or takes an immediate action might better suit your problem.
Sumit source share