I have two/three state variables stored in DB-table fields and I wonder what's the best way to toggle them (from 1 to 0 and vice versa) and return back their new value. Running two queries seems too much to me. Is there another, better way?
Here is my query now (i haven't tested it yet):
UPDATE MyTable qrus
SET qrus.favorite=(CASE WHEN (qrus.favorite=0) THEN 1 ELSE 0 END)
WHERE <sth>;
I am using OracleDataClient.
I don't know if I could insert an additional select after the update but in the same CommandText. I will try this. But isn't there a better way?