View Single Post
  #2  
Old 02-07-2007, 08:03 AM
Thalian Thalian is offline
Senior Member
 
Join Date: Jul 2006
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 18
Thalian is on a distinguished road
Default

MySQL QB has two SQL editors: the query area and the script editor. The first one is for single queries only and the other one is for multiple statements and can be used to step through the script. You are using the same delimiter for both, the command itself and the trigger text. So there must be at least a "delimiter xxx" command.
Open a script tab and put this code in:

delimiter $
CREATE TRIGGER Country_BeforeDelete BEFORE DELETE ON Country
FOR EACH ROW
BEGIN
DELETE FROM City WHERE City.ID = OLD.Capital;
END $ -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - Performing multi-line SQL statement
View Single Post
  #2  
Old 02-07-2007, 08:03 AM
Thalian Thalian is offline
Senior Member
 
Join Date: Jul 2006
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 18
Thalian is on a distinguished road
Default

MySQL QB has two SQL editors: the query area and the script editor. The first one is for single queries only and the other one is for multiple statements and can be used to step through the script. You are using the same delimiter for both, the command itself and the trigger text. So there must be at least a "delimiter xxx" command.
Open a script tab and put this code in:

delimiter $
CREATE TRIGGER Country_BeforeDelete BEFORE DELETE ON Country
FOR EACH ROW
BEGIN
DELETE FROM City WHERE City.ID = OLD.Capital;
END $ -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote