I'm working on converting a whole project from Oracle to mySql. I've been trying to figure out where the syntax is wrong here. Any ideas?
CREATE TRIGGER payment_check BEFORE DELETE ON members FOR EACH ROW
BEGIN
DECLARE v_payment_due DECIMAL(6, 2); // this line returns error
CodePudding user response:
MySQL syntax is quite a bit different from Oracle. Your trigger should look something like this:
CREATE TRIGGER payment_check
BEFORE DELETE ON members
FOR EACH ROW
BEGIN
DECLARE v_payment_due DECIMAL(6, 2);
SET @v_payment_due := 1.23;
END;
See this db<>fiddle and the answers to this SO question
CodePudding user response:
in mysql syntax is like
DELIMITER $$
CREATE TRIGGER trigger_name
BEFORE DELETE
ON table_name FOR EACH ROW
BEGIN
-- statements
END$$
DELIMITER ;
for your reference refer this link