0

I have a trigger:

CREATE DEFINER=`root`@`100.100.100.100` TRIGGER `MYSCHEMA`.`MY_TABLE_BEFORE_INSERT` BEFORE INSERT ON `my_table` FOR EACH ROW
BEGIN

IF NEW.id = 5 AND NEW.field_name = 'my_field' THEN
    INSERT INTO my_table(id, field_name, value) VALUES (9999, 'something','test');
END IF;

END

When I run the code from my front end it simply doesn't no insert the new row. ID and field_name together are always unique so this insert statement will not run more than once.

user2924127
  • 6,034
  • 16
  • 78
  • 136
  • and you should post your real code instead code that has two syntax errors visible to the nake eye – e4c5 Nov 24 '16 at 23:00
  • @e4c5 I looked this up previously, but i don't see how this works for an insert statement. – user2924127 Nov 24 '16 at 23:03
  • @user2924127 - Did you read the accepted answer to one of the [linked questions](http://stackoverflow.com/a/40517802/243925)? Quote: "A stored function or trigger cannot modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger." – Tony Nov 25 '16 at 00:58

0 Answers0