question on using transaction
-
Hi, I am writing a window desktop application which only allow single user. Then is it necessary to have transaction management for the data writing to the relational database ? The data writing operation includes several steps (ie. if the window hangs, then the operation may be corrupted). Thanks
-
Hi, I am writing a window desktop application which only allow single user. Then is it necessary to have transaction management for the data writing to the relational database ? The data writing operation includes several steps (ie. if the window hangs, then the operation may be corrupted). Thanks
sure necessary especially if your writing operation has several steps. think about if you get an error while inserting or deleting a record related to several tables. there would sure remain some unnecessary data in tables. (records that have been deleted or inserted before getting the error.)
-
sure necessary especially if your writing operation has several steps. think about if you get an error while inserting or deleting a record related to several tables. there would sure remain some unnecessary data in tables. (records that have been deleted or inserted before getting the error.)
Thanks for your reply. But my program is not for enterprise application, just for desktop single user. Is this still necessary coz the addition of transaction into my program will cause a lot of effort ? So are application like MSWord,...also adopts transactions ?
-
Thanks for your reply. But my program is not for enterprise application, just for desktop single user. Is this still necessary coz the addition of transaction into my program will cause a lot of effort ? So are application like MSWord,...also adopts transactions ?
its up to you but if i were you i would use transaction. (depending uopn your words about the writing process) anonymous wrote: So are application like MSWord,...also adopts transactions ? can you be more clear?
-
Thanks for your reply. But my program is not for enterprise application, just for desktop single user. Is this still necessary coz the addition of transaction into my program will cause a lot of effort ? So are application like MSWord,...also adopts transactions ?
MSWord is not a database, so it neither supports not needs transactions. If you are making multiple related changes to multiple taples (for example: insert new row in main table, insert new row(s) in detail table using foreign key from new row in main table) you should always enclose these in a single transaction, so that if one of the dependant changes fails (an unexpected null value, an out of range value, etc. ) you can easily cancel the preceding changes (rollback the transaction). Adding the transaction support is relatively easy, and should not take much code, Transactions really have nothing to do specifically with multi-user scenarios, instead the have to do with keeping changes consistent - preventing partial updates that could corrupt the data. Absolute faith corrupts as absolutely as absolute power Eric Hoffer The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not. Eric Hoffer