Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 793
  • Last Modified:

Rollback if trigger crashes

When I insert a record, a Trigger is fired. I want to monitor this Trigger. If Trigger executed successfully, then commit else rollback. How to get the response whether the Trigger executed successfully or not?
0
rpkhare
Asked:
rpkhare
1 Solution
 
UmeshMySQL Principle Technical Support EngineerCommented:
Khare,

Pls follow this..you will get an idea whether the insert+trigger has caused any errors...

1. START TRANSACTION;
2. INSERT INTO someTable => Some trigger fired on "AFTER|BEFORE INSERT"
3. SHOW ERRORS; or SHOW COUNT(*) ERRORS; or SELECT @@error_count;
4.
   if @@error_count > 1 then
          ROLLBACK;
   else
          COMMIT;
   end if;
0
 
rpkhareAuthor Commented:
Thanks. I'll try.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now