tags:

views:

7

answers:

1

for an prepared statement

update table t set a = ? ,b = ? where i = ?

column a to stay column a ie. a=a and only need to setInt for b and visa versa, without needing another statement. Is there a concise way of doing this?

A: 

You could try this:

UPDATE TableT
SET a = COALESCE(?, a),
    b = COALESCE(?, b)
WHERE i = ?

To leave a value unchanged, simply pass NULL in. Of course you cannot use this method if you actually wish to set the value to NULL.

Mark Byers