Problem with create trigger
Hello!
I use MySQL 5.0.7-beta-nt.
I have 2 tables:
---
CREATE TABLE "users" (
"id" int(10) unsigned NOT NULL auto_increment,
"name" varchar(45) NOT NULL,
"number" int(10) unsigned NOT NULL default '1',
PRIMARY KEY ("id")
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
---
CREATE TABLE "shots" (
"id" int(10) unsigned NOT NULL auto_increment,
"id_user" int(10) unsigned NOT NULL,
"total" int(10) unsigned NOT NULL,
PRIMARY KEY ("id"),
KEY "FK_shots_1" ("id_user"),
CONSTRAINT "FK_shots_1" FOREIGN KEY ("id_user") REFERENCES "users" ("id")
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
---
I want create trigger on delete from table USERS, which delete rows from table SHOTS on shots.id_user = users.id.
I write so:
---
CREATE TRIGGER on_del BEFORE DELETE ON users
FOR EACH ROW
BEGIN
DELETE FROM shots WHERE id_user = OLD.id
END
---
But MySQL return that error:
---
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'DELET
E FROM shots WHERE id_user = OLD.id
END' at line 4
---
What error i make?
Subject
Views
Written By
Posted
Problem with create trigger
3402
July 08, 2005 12:14AM
2227
July 08, 2005 01:29AM
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.