mysql trigger not working? -
i trying create trigger insert new row conditionally based on insert on table...i can't seem nail syntax. here have far:
delimeter $$ create trigger overpricedcar after insert on cars each row begin if (new.sellprice > '80000' )then insert listings values(new.carname,'gold','0',' '); end if; end$$ delimeter ;
for reason keep getting error, syntax seems ok, i'm not sure may have gone wrong.
edit
after correcting typo, trigger 'works'.
i have added comment output when trigger happens. have tested it, , output message gets printed screen trigger not complete inserts:
delimiter $$ create trigger overpricedcar before insert on cars each row begin if (new.sellprice > '80000' )then insert listings values(new.carname,'gold','0',' '); signal sqlstate '45000' set message_text = "new gold car!"; // line throws off end if; end$$ delimiter ;
where can place messages want printed screen when trigger runs?
typo:
delimeter ^--- should i: delimiter
Comments
Post a Comment