Try Catch, And Multiple Mysql Insert Statement. Will It Accept All Or Deny All Queries?
Hey I have question to you guys. If I implement my sql mysql insert in try catch will that prevent from executing only partial INSERT into database if one of them will fail ? try {
Solution 1:
No. try/catch will NOT "undo" failed queries if one of those fails. You need a transaction:
try {
start transaction;
insert 1;
insert 2;
...
commit;
} catch {
rollback;
}
Solution 2:
you should use transactions and rollback in the catch block.
Post a Comment for "Try Catch, And Multiple Mysql Insert Statement. Will It Accept All Or Deny All Queries?"