I need to create a dynamic update statement to be be executed by a jdbc:outbound-channel-adapter, because I need to set one field using a case expression that has variable number of conditions as follows:
UPDATE tableA
SET fieldA = CASE
WHEN fieldB IN ('a','b') THEN 1
WHEN fieldB IN ('c','d') THEN 2
...
WHEN fieldB IN (...) THEN N
END
WHERE fieldC = :headers[MY_FIELDC]
I can create this dynamic update statement in a Spring expression as follows:
"'UPDATE tableA SET fieldA = ' + headers[MY_CASE_EXP] + ' WHERE fieldC = :headers[MY_FIELDC]'"
But the query attribute does not seem to support Spring expressions.
How can I generate a dynamic query for use by the jdbc:outbound-channel-adapter?