MySQL Forums
Forum List  »  InnoDB

Error 1337 VARIABLE OR CONDITION DECLARATION AFTER CURSOR OR HANDLER DECLARATION
Posted by: Marco Erni
Date: December 27, 2005 07:32AM

hi at all:-)
I've some problems with a short procedure which i have written. Here whole database and the procedurescript:



create database testdb;
use testdb;
CREATE TABLE test1 (
ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
a INTEGER UNSIGNED NULL,
PRIMARY KEY(ID)
);

CREATE TABLE test2 (
ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
a INTEGER UNSIGNED NULL,
PRIMARY KEY(ID)
);

Insert into test1 set a = 2;
Insert into test1 set a = 4;
Insert into test1 set a = 6;
Insert into test1 set a = 8;
Insert into test1 set a = 10;

delimiter $$
CREATE PROCEDURE testdb.curdemo()
BEGIN
Declare cur1 Cursor For select a from testdb.test1;
Declare temp INT;
declare done INT Default 0;
Declare continue handler for Sqlstate '02000' set done = 1;

open cur1;

Repeat
fetch cur1 into temp;
IF Not done then
Insert into test2 set a = temp;
End if;
Until done END Repeat;
close cur1;
End $$
delimiter ;



Now, if i would add the procedure, Mysql requests a error: Error 1337 VARIABLE OR CONDITION DECLARATION AFTER CURSOR OR HANDLER DECLARATION at line 22
Where is my bug?

Thanks for your help.
Marco

Options: ReplyQuote


Subject
Views
Written By
Posted
Error 1337 VARIABLE OR CONDITION DECLARATION AFTER CURSOR OR HANDLER DECLARATION
28874
December 27, 2005 07:32AM
8649
December 27, 2005 08:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.