// Deletion must occur in reverse order.
// first call - crete temp table.
// may fail in case global temp table already exists.
try {
DatasourceCall databseCall = (DatasourceCall)getCalls().elementAt(getCalls().size() - 1);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
// ignore
}
// second call - populate temp table.
// if that fails save the exception and untill cleanup
if(ex == null) {
try {
DatasourceCall databseCall = (DatasourceCall)getCalls().elementAt(getCalls().size() - 2);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
ex = databaseEx;
}
}
// third (a call per table) - delete from original tables calls.
// if that fails save the exception untill cleanup
for (int index = getCalls().size() - 3; index >= 1 && ex == null; index--) {
DatasourceCall databseCall = (DatasourceCall)getCalls().elementAt(index);
try {
// returns the number of rows removed from the first table in insert order
returnedRowCount = (Integer)executeCall(databseCall);
} catch (DatabaseException databaseEx) {
ex = databaseEx;
}
}
// last call - cleanup temp table.
// ignore exceptions here.
try {
DatasourceCall databseCall = (DatasourceCall)getCalls().elementAt(0);
executeCall(databseCall);
} catch (DatabaseException databaseEx) {
// ignore
}