AeOn
AeOn

Reputation: 25

SQL syntax error in mysql when creating trigger

I have a problem when creating a trigger in mysql i get this error:

#1064 - 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 '' at line 7

This is my first time creating triggers for mysql help

Here is the code:

        CREATE TRIGGER insertAfterUser AFTER INSERT ON MEMBERS    
        FOR EACH ROW    
        BEGIN    
        INSERT INTO blagajna (MemberId,StanjeRacuna) VALUES(12,0.0);    
        END;

Upvotes: 0

Views: 47

Answers (2)

Sharma Vikram
Sharma Vikram

Reputation: 2480

CREATE TRIGGER `insertAfterUser ` BEFORE INSERT ON `members` FOR EACH ROW BEGIN INSERT INTO   blagajna (MemberId,StanjeRacuna) VALUES('12','0.0'); END;                         

Upvotes: 1

vaso123
vaso123

Reputation: 12391

You need to set the delimiter

delimiter //
CREATE TRIGGER insertAfterUser AFTER INSERT ON MEMBERS    
      FOR EACH ROW    
      BEGIN    
      INSERT INTO blagajna (MemberId,StanjeRacuna) VALUES(12,0.0);    
      END;//
delimiter ;

Upvotes: 1

Related Questions