I am often having a very hard time to create a stored procedure in mysql. Syntax which should really be fine just get not parsed within a stored procedure. Here is a simplified version that still doesn't get parsed. I am not able to turn this code into something that can be parsed.
The update..set clause gives problems
UPDATE
I've simpiflied the code even more. Problem still exists. Error messages seems to be rumble
UPDATE 2
Solved, thanks to Mark Byers. The into
clause in a select
-statement must be positioned carefully. Note how misleading and bad the mysql error mesage is!
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
UPDATE page SET lft = 1 where lft > 3 AN' at line 22
The code:
CREATE PROCEDURE `move_page_right`( subject_id SMALLINT UNSIGNED, reference_id SMALLINT UNSIGNED)
BEGIN
select
p.lft,
p.rgt,
p.rgt - p.lft,
p.rgt + 1
into
@subject_old_lft,
@subject_old_rgt,
@subject_width,
@subject_old_right_sibling_lft
from page p
where p.page_id = subject_id;
select p.rgt + 1
from page p
into @subject_new_lft
where p.page_id = reference_id;
UPDATE page
SET
lft = 1
where lft > 3 AND lft < 3;
END