Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

SQL Syntex Parse Error..

devkorea's profile image devkorea posted 7 years ago in Running SQL scripts Permalink
DROP TRIGGER IF EXISTS trgInsertA_SomeTable;
CREATE TRIGGER trgInsertA_SomeTable AFTER INSERT ON SomeTable
FOR EACH ROW BEGIN
-- -------------------------------------------------------
-- Comment
-- -------------------------------------------------------
DECLARE __SomeColumn VARCHAR(3) DEFAULT '0'; -- Column Comment

-- to do...
END;


SQL Error (1064): 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 8

devkorea's profile image devkorea posted 7 years ago Permalink

DROP TRIGGER IF EXISTS trgInsertA_SomeTable;
CREATE TRIGGER trgInsertA_SomeTable AFTER INSERT ON SomeTable
FOR EACH ROW BEGIN
-- -------------------------------------------------------
-- Comment
-- -------------------------------------------------------
DECLARE __SomeColumn VARCHAR(3) DEFAULT '0'; -- Column Comment

-- to do...
END;


SQL Error (1064): 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 6

ansgar's profile image ansgar posted 7 years ago Permalink
HeidiSQL splits queries at semicolons by default. Your CREATE TRIGGER query has a semicolon within itself. Look at the line which ends with "... DEFAULT '0';"

You need to change the query delimiter for HeidiSQL, so it's not semicolon but something else. You can either change the delimiter using the button with the red semicolon on it, on the main toolbar. Or by adding a client-side DELIMITER command:
DELIMITER //
DROP TRIGGER... //
CREATE TRIGGER trgInsertA_SomeTable AFTER INSERT ON SomeTable
FOR EACH ROW BEGIN
DECLARE __SomeColumn VARCHAR(3) DEFAULT '0'; -- Column Comment
-- to do...

END//
DELIMITER ;
devkorea's profile image devkorea posted 7 years ago Permalink
thank a lot..
Have a good day!!

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.