Subject Query regarding exceptions during Post prevent transaction Commit
Author Colin Fraser
Could someone please let me know the best way to do the following...

I had a BDE app that roughly did the following (I have now converted it to
IBO)

The app goes through an audit trail of changes made to another system and
updates the Interbase DB.

The sequence of events are something like as follows:
Start a transaction
for the number of audit entries do
try
Insert/Update a record in table A, B or C
except
Log the error
end;
End the transaction.

Now, say that the insert into table a table fails due to some foreign key
constraint. The exception is raised by the Post procedure of the cursor used
to update the table. When the App was a BDE app the system would continue
(after logging the error) updating and inserting into the tables. Then the
transaction would end.

But with IBO, if an exception is raised by the post procedure, it is not
cancelled... if you try and later end the transaction even after updating
lots of other tables/records, the transaction fails to commit due to the
error encountered earlier.

So, do I need to put a try except around every TIB_Cursor.Post and if an
exception is raised, cancel the Insert or Update and then re-raise the error
(so the log can be generated).... This is a bit more work than it sounds as
there are quite a few Posts around the app (unlike the simple example
above).

To summarize, should you always put a Post in a try.. except and then cancel
the post if it doesn't work so the rest of the updates in the transaction
can be committed, or alternatively, should you start a new transaction,
edit/insert, post, commit for every entry in the Audit.

Sorry for the long description

Regards

C Fraser



######################################################################
Attention:
The information in this email and in any attachments is confidential.
If you are not the intended recipient then please do not distribute,
copy or use this information. Please notify us immediately by return
email and then delete the message from your computer.
Any views or opinions presented are solely those of the author.
######################################################################