I find it hard to find an error when trying to create a stored procedure in mysql.
if I run each individual line of the procedure independently, everything works fine.
CREATE PROCEDURE cms_proc_add_child (param_parent_id INT, param_name CHAR(255), param_content_type CHAR(255)) BEGIN SELECT @child_left := rgt FROM cms_tree WHERE id = param_parent_id; UPDATE cms_tree SET rgt = rgt+2 WHERE rgt >= @child_left; UPDATE cms_tree SET lft = lft+2 WHERE lft >= @child_left; INSERT INTO cms_tree (name, lft, rgt, content_type) VALUES (param_name, @child_left, @child_left+1, param_content_type); END
I get the following (useful) error: ERROR 1064 (42000): you have an error in the SQL syntax; check the manual that matches your MySQL server version for the correct syntax to use next to '' on line 3 ... I just don't know where to start debugging, since each of these lines is correct.
any advice?
mysql stored-procedures
Pierre spring
source share