Im attempting to write a SQL procedure, unfortunately, since this is my first, it's not going well. This is what I have:
Unfortunately, I get the following error message:
#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 'procedure restore_from_edit
begin
declare done int default 0' at line 1
I would appreciate any help anyone could give me. Thank you.
Code:
create procedure restore_from_edit()
begin
declare done int default 0;
declare cur1 cursor for (select pe.message, max(pe.editnum), pe.postid from page_edits pe group by pe.pageid);
declare continue handler for sqlstate '02000' set done = 1;
open cur1;
repeat
fetch cur1 into msg, enum, pid;
if not done then
update page p set p.pagetext = msg where p.pageid = pid and p.pagetext = '***';
end if
until done end repeat
close cur1
end
Unfortunately, I get the following error message:
#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 'procedure restore_from_edit
begin
declare done int default 0' at line 1
I would appreciate any help anyone could give me. Thank you.