Home > Back-end >  Consult FIREDAC significant problems
Consult FIREDAC significant problems

Time:11-10

With FIREDAC currently developing, but found a big problem, cannot be solved, and give directions:
Namely: the transaction processing, cannot capture the FIREDAC abnormalities, schedule of lead to the main table and update the data, the transaction is invalid

Used UNIDAC can capture the abnormal code segment, and perform the transaction rollback, but FIREDAC, anyway could not perform abnormal code,
Has been executed in accordance with the normal order, crazy, don't know who treated with FIREDAC transaction exception handling, give advice or comments please!

The code is as follows:


Try
//start transaction
Datamodform. DBCONN. StartTransaction;

Qry_purpo3. ApplyUpdates ();
Qry_detail. ApplyUpdates ();
Qry_master. ApplyUpdates ();

//there is no mistake, formally submitted all changes
Datamodform.DBCONN.Com MIT;

Qry_purpo3.Com mitUpdates;
Qry_detail.Com mitUpdates;
Qry_master.Com mitUpdates;

//save, after data as read-only state
Set_query_status (qry_master, 'R');
Set_query_status (qry_detail, 'R');
Set_query_status (qry_purpo3, 'R');


Completed application. MessageBox (pchar (' saved! ', 'information', MB_ICONINFORMATION + MB_OK);


Except on e: the Exception do
The begin
//when an error occurs, the rollback all the modified data
If datamodform. DBCONN. InTransaction then
Datamodform. DBCONN. RollBack;

Application. MessageBox (pchar (' an error occurred while trying to save the data! '+ # 13 # 10 + e.m essage),
'wrong', MB_ICONERROR + mb_ok);
end;

end;

CodePudding user response:

 

The begin
Datamodform. DBCONN. StartTransaction;
Try
Qry_purpo3. ApplyUpdates ();
Qry_detail. ApplyUpdates ();
Qry_master. ApplyUpdates ();

Qry_purpo3.Com mitUpdates;
Qry_detail.Com mitUpdates;
Qry_master.Com mitUpdates;

//save, after data as read-only state
Set_query_status (qry_master, 'R');
Set_query_status (qry_detail, 'R');
Set_query_status (qry_purpo3, 'R');

Completed application. MessageBox (pchar (' saved! ', 'information', MB_ICONINFORMATION + MB_OK);
Datamodform.DBCONN.Com MIT;
Except,
Application. MessageBox (pchar (' an error occurred while trying to save the data! '+ # 13 # 10 + e.m essage),' mistakes', MB_ICONERROR + mb_ok);
Datamodform. DBCONN. Rollback;
end;
end;

CodePudding user response:

 

The begin
Datamodform. DBCONN. StartTransaction;
Try
Qry_purpo3. ApplyUpdates ();
Qry_detail. ApplyUpdates ();
Qry_master. ApplyUpdates ();

//save, after data as read-only state
Set_query_status (qry_master, 'R');
Set_query_status (qry_detail, 'R');
Set_query_status (qry_purpo3, 'R');

Completed application. MessageBox (pchar (' saved! ', 'information', MB_ICONINFORMATION + MB_OK);
Datamodform.DBCONN.Com MIT;
Except,
Application. MessageBox (pchar (' an error occurred while trying to save the data! '+ # 13 # 10 + e.m essage),' mistakes', MB_ICONERROR + mb_ok);
Datamodform. DBCONN. Rollback;
end;
end;

CodePudding user response:

In addition, the code you write in where? If written in the ApplicationEvents onException event, please check the code associated with whether onException event,

CodePudding user response:

How did you write this to see your update statement, written in the book? If it is TFD * *. ExecSQl (' Update (SQL)... '), it is executed in the database, Delphi connection transaction, is less than the wrong response

CodePudding user response:

Is to be able to check error trapping through database events
  • Related