Menu

#769 MySQL5 Trigger support (just SQL first)

Next_minor_version
fixed
5
2013-06-11
2005-08-23
No

It would be nice if the SQL parser would recognize
"CREATE TRIGGER" sql statements and just change
DELIMITER for this single statement to something not
used in the statement, i.e. "//".

Example query:

CREATE TRIGGER trigger_documents_forum_delete AFTER
DELETE ON documents
FOR EACH ROW
BEGIN
IF OLD.document_category_id=2 THEN
UPDATE forum_postings SET last_update=NOW() WHERE
node_id=OLD.foreign_id;
END IF;
END;

phpMyAdmin should execute automatically before a
"CREATE TRIGGER" statement:

DELIMITER //

and after the "CREATE TRIGGER" statement:

//
DELIMITER ;

Conclusion: Each single "CREATE TRIGGER" statement
should be surrounded automatically by two DELIMITER
statements.
The working example from the MySQL 5.0.11 command line is:

DELIMITER //
CREATE TRIGGER trigger_documents_forum_delete AFTER
DELETE ON documents
FOR EACH ROW
BEGIN
IF OLD.document_category_id=2 THEN
UPDATE forum_postings SET last_update=NOW() WHERE
node_id=OLD.foreign_id;
END IF;
END;//
DELIMITER ;

GUI support for triggers could be added later of course ;)

Best regards,
René Leonhardt

Discussion

  • Marc Delisle

    Marc Delisle - 2008-07-19

    Logged In: YES
    user_id=210714
    Originator: NO

    This was implemented some time ago.

     
  • Marc Delisle

    Marc Delisle - 2008-07-19
    • assigned_to: nobody --> lem9
    • status: open --> closed-accepted
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-accepted --> fixed
     
MongoDB Logo MongoDB