-
Transaction Query
Hi All,
In my code I need to copy a file from one location to another and then perform a database operation.
The problem is that I need to wrap this up in a tranaction and am not sure how best to cope with it.
Should I wrap up the file copy operation in a try catch block ?
Should I wrap it all up.
I am just noth sure of the tidiest solution and was wondering how you guys managed this type of operation.
Thanks In Advance
-
Re: Transaction Query
You should always use Try/Catch blocks whenever something can go wrong (search for Murhpy's law :D).
I my opinion you have two solutions:
1) begin the transaction (thus locking affected rows)
2) copy your file (into a try/catch block)
3) do your queries in the database (into another try/catch block)
4) commit
OR
0) Try
1) begin the transaction (thus locking affected rows)
2) copy your file
3) do your queries in the database
4) commit
5) Catch ...
Rollback if something goes wrong...
I think the first solution is more flexible...
Best regards,
Xmas.