Phil S
Phil S

Reputation: 197

Create trigger in MariaDB

We're currently looking to port from Oracle into MariaDb, but are struggling to recreate old triggers.

Specifically, we're currently trying to execute:

CREATE DEFINER=`admin`@`%` TRIGGER SET_AUTHOR_EVENT_ID BEFORE INSERT ON author_event
FOR EACH ROW 
BEGIN
    SET NEW.ID = AUTHOR_EVENT_ID_SEQ.NEXTVAL;
END;

but are getting the following error message :

SQL Error [1064] [42000]: (conn=3153) 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 ‘’ at line 1

The syntax we're using appears to be inline with the documentation we can find, but there's definitely an error in there somewhere. Looking into the specifics of the error message (i.e. 1064) appears to yield few clues...any help/pointers/suggestions gratefully received.

Thanks

Upvotes: 1

Views: 832

Answers (1)

andreyro
andreyro

Reputation: 985

Adding DELIMITER as Paul said, worked for me.

DELIMITER $$    
CREATE DEFINER=`admin`@`%` TRIGGER SET_AUTHOR_EVENT_ID BEFORE INSERT ON author_event
FOR EACH ROW 
BEGIN
    SET NEW.ID = AUTHOR_EVENT_ID_SEQ.NEXTVAL;
END; 
$$

Upvotes: 0

Related Questions