On 29/11/2014 14:50, Dyre Tjeldvoll wrote:
I think the SQL-standard way of doing things like this is with the MERGE
statement <http://db.apache.org/derby/docs/10.11/ref/rrefsqljmerge.html> (just
added to Derby in the latest release). Though the syntax may be a bit more
cumbersome…

A *lot* more cumbersome, if I understand it correctly! But perhaps you could convince me otherwise by posting a snippet to show me how to do it?

Basically, I'd just like to be able to do this:

  try (Transaction t = new Transaction(connection)) {
    //... insert new row
    t.commit();
  }
  catch (SQLDuplicateKeyException e) {
    // ... update existing row
    t.commit();
  }

... and let any other exceptions propagate. As it is, having to use an "if" to distinguish between different exceptions is very ugly and non-O-O.

--
John English

Reply via email to