DbExternalVariable evar = _vars.get(evarId);
if (evar == null)
throw new ExternalVariableModuleException("No such variable. "); // todo
RowVal val = evar.parseXmlRow(evar.new RowVal(), (Element) newval.value);
RowKey key = evar.keyFromLocator(newval.locator);
if (key.isComplete() && evar._initType == InitType.delete_insert) {
// do delete...
// TODO
}
// should we try an update first? to do this we need to have all the required keys
// and there should be some keys
boolean tryupdatefirst = (evar._initType == InitType.update || evar._initType == InitType.update_insert)
&& !evar._keycolumns.isEmpty() && key.isComplete();
boolean insert = evar._initType != InitType.update;
try {
if (tryupdatefirst)
insert = execUpdate(evar, val) == 0;
if (insert) {
key = execInsert(evar, newval.locator, val);
// Transfer the keys obtained from the db.
key.write(newval.locator);
}
} catch (SQLException se) {
throw new ExternalVariableModuleException("Error updating row.", se);
}