MySQL Forums
Forum List  »  Triggers

Before Insert Trigger
Posted by: Pete Elliott
Date: July 28, 2019 04:32PM

I have a table (chain) which has unique identifiers under TagId column re: numbers 1 through to 50.

I am trying to set up a trigger which inserts into another table (chain_gear) however I only wish to show TagId "11" within the chain_gear table

I cannot seem to be able to use "WHERE" statements or "IF" statements within the trigger

The present trigger query I have is quite simple and is updating my chain_gear table but it is updating it with all the other TagId as it is and I only need it to update entries for TagId "11", present code is below:

CREATE TRIGGER `chain`.`chain_tagshistory_BEFORE_INSERT` BEFORE INSERT ON `chain_tagshistory` FOR EACH ROW
INSERT INTO chain_gear (TagId, Val, _date)
VALUES (NEW.TagId, NEW.Val, NEW._date);

Options: ReplyQuote

Written By
Before Insert Trigger
July 28, 2019 04:32PM
July 28, 2019 08:19PM

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.