On 14/05/2014 17:35, John English wrote:
delete from Foo where A=? and B=?
However, when the value for B is null, nothing gets deleted (presumably due to
the query containing B=NULL rather than B IS NULL).
I now have this, which works (but is rather ugly)... I'd be grateful if anyone
can tell me a more elegant way to do it:
try (Transaction t = db.startTransaction()) {
if (b == null) {
db.update("delete from Foo where A=? and B is null", a);
}
else {
db.update("delete from Foo where A=? and B=?", a, b);
}
update("insert into Foo values(?,?)", a, b);
t.commit();
}
--
John English