Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Which table failed in a transaction?
Sun, Feb 20 2022 11:07 PMPermanent Link

Ian Branch

Avatar

Hi Team,
I have a transaction working on multiple tables inside a Try-Except-End.
It starts off with..
{code}
 SetLength(aTablesArray, 5);
 //
 aTablesArray[0] := 'LineItems';
 aTablesArray[1] := 'Parts';
 aTablesArray[2] := 'BackOrders';
 aTablesArray[3] := 'JobTickets';
 aTablesArray[4] := 'APJobTickets';
 //
 dmS.DBC1.StartTransaction(aTablesArray);
 //
 try
   //
....
....
{code}
And ends with..
{code}
   //
   dmS.DBC1.Commit;
   //
 except
   dmS.DBC1.RollBack;
   LineItems.Refresh;
   //
   TaskMessageDlg('Unable to issue Part!', 'The part was not able to be Issued to the Job Ticket at this time.' + sLineBreak +
     'Another application may have one or more of the relevant records open for editing at this time.' + sLineBreak + 'Please retry a little later.', mtError,
     [mbOK], 0);
   //
   //
 end;
{code}
How can I tell, if I can at all, which of the tables caused the transaction to fail??
Of course the failure may not be due to a table action but I would like to be able to tell.

Regards & TIA,
Ian
Mon, Feb 21 2022 10:12 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Ian,

You can obtain detailed information about the error that causes the exception to happen using the EEDBError object.
Take a look into these manual sections (there is an example on how to use it):

https://www.elevatesoft.com/manual?action=viewtopic&id=edb2&product=rsdelphiwin32&version=11&topic=Exception_Handling
https://www.elevatesoft.com/manual?action=viewcomp&id=edb2&product=rsdelphiwin32&version=11&comp=EEDBError

--
Fernando Dias
[Team Elevate]
Mon, Feb 21 2022 10:14 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Unless the information is in ElevateDB's error message I don't know of a built in method. What I tend to do (not just in transactions) is have a "progress variable" and set its value as a program / script progresses. When the exception is triggered then you can report the progress as well. I've used both string and integer variables.

Roy Lambert
Image