I want to do an update on my table using the following CASE-WHEN logic:
UPDATE table1
SET Volume_eur =
CASE
WHEN TradeCode = 'A' THEN PaymentAmount_field1
WHEN TradeCode = 'B' THEN PaymentAmount_field2
WHEN TradeCode = 'C' THEN PaymentAmount_field3
END
* CurrencyRate/100
FROM table1
But I want to document which logic was used and stamp that on the Statusfield. So basically I want to do an update-statement inside my CASE-WHEN sentence like this: (marked with bold)
UPDATE table1
SET Volume_eur =
CASE
WHEN TradeCode = 'A' THEN PaymentAmount_field1
UPDATE table1 SET StatusField = 'Logic1'
WHEN TradeCode = 'B' THEN PaymentAmount_field2
UPDATE table1 SET StatusField = 'Logic2'
WHEN TradeCode = 'C' THEN PaymentAmount_field3
UPDATE table1 SET StatusField = 'Logic3'
END
* CurrencyRate/100
FROM table1
Is that possible, or how should I do it? I would like to avoid copying the whole CASE-WHEN logic since it will become harder to maintain it.