Datasnap and Transactions
Posted: Wed 17 Oct 2012 04:56
Hi
I am trying to get transactions working correctly with Datasnap and nested ClientDataSets (CDS).
What I have on the server is my master CDS and a detail CDS (nested). I have a master TIBCQuery and detail TIBCQuery. I have a TIBCUpdateSQL associated with the master query and a specific insert object associated with the master query.
I have a default transaction which has an DefaultCloseAction property of taCommit. I have created a 2nd transaction which has a DefaultCloseAction of taRollback. I have associated the UpdateTransaction property of my master query to this as well as the TIBCUpdateSQL.InsertObject TIBCQuery.
What is happening is when I insert a new record (for example), my master record is being commited before writing the detail record. Therefore if an exception occurs after the master insert has taken place, the record has already been written to the DB and isn't rolled back.
I think this is to do with the AutoCommit property. If it turn it off of my Insert TIBCQuery, then it doesn't write the record to the database.
I have had a look at the MIDAS demo shipped but is very old and doesn't deal with nested CDS. Am I using your components the right way?
Thanks
I am trying to get transactions working correctly with Datasnap and nested ClientDataSets (CDS).
What I have on the server is my master CDS and a detail CDS (nested). I have a master TIBCQuery and detail TIBCQuery. I have a TIBCUpdateSQL associated with the master query and a specific insert object associated with the master query.
I have a default transaction which has an DefaultCloseAction property of taCommit. I have created a 2nd transaction which has a DefaultCloseAction of taRollback. I have associated the UpdateTransaction property of my master query to this as well as the TIBCUpdateSQL.InsertObject TIBCQuery.
What is happening is when I insert a new record (for example), my master record is being commited before writing the detail record. Therefore if an exception occurs after the master insert has taken place, the record has already been written to the DB and isn't rolled back.
I think this is to do with the AutoCommit property. If it turn it off of my Insert TIBCQuery, then it doesn't write the record to the database.
I have had a look at the MIDAS demo shipped but is very old and doesn't deal with nested CDS. Am I using your components the right way?
Thanks