MySQL server version for the right syntax to use near '' at line

I found similar problems but they always were in php.

code

CREATE TRIGGER PL_gl
BEFORE INSERT ON Zaznam_o_vstrel_br
for each row 
BEGIN 
IF (NEW.Autor_branky IS NOT NULL) then 
UPDATE hrac 
SET Pocet_golu = Pocet_golu + 1 
WHERE ID_num = NEW.Autor_branky; /*ERROR HERE*/
END IF;
END;

I made so much modifications that I already don't know how is it correct.

hrac contains:

create table hrac (   
ID_num INT AUTO_INCREMENT Primary key,
Jmeno VARCHAR (50) NOT NULL,
Jmeno_tymu VARCHAR (50) NOT NULL,
Datum_narozeni DATE,
Domovsky_klub VARCHAR (50),
Cislo_dresu INT,
Pocet_golu INT);

Error says 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 9. That doesn't tells me anything so I tried at least 20 combinations. And in SQL it worked without any problem.

Answers


Assuming the SQL is correct, here is what I believe is going on. In your begin... end statement, you have statements that end in semicolons, and it hits the one on line 9, and it thinks you've finished defining the trigger. The trigger at that point isn't defined with correct syntax, so it fails. Try defining a new delimiter this before your first statement:

DELIMITER //

Then, instead of putting a semicolon after your END statement, use the new delimiter:

END //

That will enable you to use semicolons in your trigger without a syntax error.


Need Your Help

Layout And Views Visibility on app

java android listview layout

I was testing my android app on device by enabling device show layout boundaries in developer option on device.

Delete all tables in Derby DB

java sql jdbc derby

How do i delete all the tables in the schema on Apache Derby DB using JDBC?