MySQL Forums
Forum List  »  Triggers

Executing multiple statements upon delete trigger
Posted by: Mark Young
Date: November 04, 2011 07:43AM

Upon the deletion of a row I want to execute multiple SQL statements to delete content from other tables, but I keep getting an SQL syntax error. Due to the nature of my application I cannot state the table or column names but I have modified them. My query to create the trigger is:

CREATE TRIGGER myTrigger BEFORE DELETE ON table1
FOR EACH ROW
BEGIN
DELETE FROM table2 WHERE table1ID= OLD.table1ID;
DELETE FROM table3 WHERE table1ID= OLD.table1ID;
DELETE FROM table4 WHERE table1ID= OLD.table1ID;
END

For the purposes of the code above, lets say that table1ID is a foreign key for table2, table3 and table4.

What is wrong with the above syntax? Am I missing something very obvious?

Options: ReplyQuote


Subject
Views
Written By
Posted
Executing multiple statements upon delete trigger
2846
November 04, 2011 07:43AM


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.