Re: BEFORE INSERT trigger > how to rollback the insertion
Posted by: Peter Brawley
Date: April 01, 2015 01:36PM

The only way to "cancel" an issued Insert or Update or Delete command is to Rollback the transaction containing the command. MySQL Triggers can't Commit or Rollback; such transaction code has to be outside the actual Insert, Update or Delete logic, ie ...

start transaction
insert (evoking triggers &c)
commit on success or rollback on failure

INSERT IGNORE is designed to solve your problem---the IGNORE keyword tells MySQL not to insert the row if it contains a primary or unique value that exists in the table

Options: ReplyQuote


Subject
Written By
Posted
Re: BEFORE INSERT trigger > how to rollback the insertion
April 01, 2015 01:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.