Client Transaction

I’ve a firebird DB. But no define Master Detail relation in the DB Level.

But I define the master detail relation Manually in DataAbstract Schema. It is Multi Level Detail.

Relation defined as follow:

Name:fK_Inv_Mtr_Det
MasterDatabaseName: INV_MTR
MasterFields: INV_ENTITY_ID_PK;INV_ID_PK
DetailDatabaseName: INV_DET
DetailFields: INVD_ENTITY_ID_PK;INVD_ID_PK

Name:fK_Inv_BATCHS
MasterDatabaseName: INV_DET
MasterFields: INVD_ENTITY_ID_PK;INVD_BATCHS_LINK_ID_FK
DetailDatabaseName: BATCH_SERIAL_TBL
DetailFields: BATCHS_ENTITY_ID_PK;BATCHS_LINK_ID_FK

The Server is defined as above.

In Client side, I can define the master detail successfully by using where option linking. I can display the data relation correctly.

But the problem in transaction, if one of the table data record has problem cant save, I expect all data roll back. But the case is all data is saved except the problem data. I want to ask how to achieve the following:

Db level, No Defined Foreign Key for Master Detail relation but build the relation manually in DataAstract Schema.

In Client Side, I only issue the Top level Table Applyupdates procedure , it can save successfully or roll back all Change in all Table when hit error

Any Advise?

I also use the default server come with the sample server and the Multi Level Detail sample project. I added a exception in the OrderDetails on DB Before Update Trigger, if QTY=5 raise exception. Then I change the clients and Orders and OrdersDetail at the same time and make QTY=5. When I press update, there is exception come out and a DAReconcileProvider dialog, I select cancel all changes. I suppose all changes is roll back but The result is all other data saved except the Orderdetails data, How can I achieve if error all roll back. Please advise

Hello,

Master-detail relationship guaranteed that records are inserted in master table first, then in details table. And deletes are processed the other way - first all detail records are deleted and then appropriate master record.

If you need that any error in detail table during update initiated rolling back all the changes in appropriate master table - you should take care about it yourself. Set Business Processor property RaiseExceptionAtError to True in irder to achieve this - this option allows to rollback transaction even if at least one change in any delta is failed. If you don’t use Business processors components on DataService set this option in DataService.onBusinessProcessorAutoCreated event:

procedure TDataService.DataAbstractServiceBusinessProcessorAutoCreated( aSender: TRORemoteDataModule; BusinessProcessor: TDABusinessProcessor); begin BusinessProcessor.RaiseExceptionAtError:=true; end; But this does rollback only on the server - on the client you will see changed data. In order to see original data on the client too do CancelUpdates: try ClientDataModule.tbl_MasterTable.ApplyUpdates(); except ClientDataModule.tbl_MasterTable.CancelUpdates(); end;

Hope this helps