LINUX.ORG.RU

Помогите с триггером

 ,


0

1
MariaDB [(none)]> use bookbiz;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [bookbiz]> CREATE TRIGGER delcascadetrig
    -> ON titles
    -> FOR DELETE
    -> AS
    -> DELETE titleauthors
    -> FROM titleauthors, deleted
    -> WHERE titleauthors.title_id = deleted.title_id;

out:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the
right syntax to use near 'ON titles
FOR DELETE
AS
DELETE titleauthors
FROM titleauthors, deleted
WHERE tit' at line 2


Синтаксис CREATE TRIGGER должен быть совсем другой. Пардон что так капитаню, но какой вопрос...

goingUp ★★★★★
()

Что не так ?

CREATE TRIGGER delcascadetrig BEFORE DELETE ON titles
FOR EACH ROW
BEGIN
DELETE FROM titleauthors
    WHERE titleauthors.title_id = titles.title_id
END

out:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line 6

Xwo
() автор топика
Ответ на: комментарий от Xwo

Проще всего убрать BEGIN END, оно здесь не нужно.

goingUp ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.