MySQL Forums
Forum List  »  InnoDB

Fetch of a cursor does not transport data into a variable
Posted by: Notker Schlager
Date: November 25, 2008 10:55AM

Hello to all,

i created a stored procedure for MySQL. There I encountered the problem that on fetching the data of a given cursor is not put into the variable. I don't know
why, or whether there are special settings necessary.

See below the tables and the procedure:

CREATE TABLE /*!32312 IF NOT EXISTS*/ "k1" (
"idno" int(10) unsigned NOT NULL AUTO_INCREMENT,
"txt" varchar(50) DEFAULT NULL,
PRIMARY KEY ("idno")
) AUTO_INCREMENT=11 /*!40100 DEFAULT CHARSET=latin1*/;

CREATE TABLE /*!32312 IF NOT EXISTS*/ "log" (
"idmsg" int(10) unsigned NOT NULL AUTO_INCREMENT,
"msg" text,
PRIMARY KEY ("idmsg")
) AUTO_INCREMENT=151 /*!40100 DEFAULT CHARSET=latin1*/;

drop procedure if exists cursorExample;

DELIMITER //
CREATE PROCEDURE cursorExample()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE i INT DEFAULT 0;
DECLARE idno INT;
DECLARE txt VARCHAR(50);

DECLARE k CURSOR FOR SELECT idno FROM k1;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

OPEN k;

FETCH k INTO idno ;

WHILE not done DO
INSERT INTO log (msg) VALUES(NOW() );
SET i=i+1;
INSERT INTO log (msg) VALUES(i);
INSERT INTO log (msg) VALUES(idno );

FETCH k INTO idno;
END WHILE;
END;
//
DELIMITER ;



delete from log;
call cursorExample();


Can you please help me to identify the problem? Can there be some server settings a problem for reading cursors?

Thank you for your help
Kindly regards,
Notker Schlager

Options: ReplyQuote


Subject
Views
Written By
Posted
Fetch of a cursor does not transport data into a variable
4723
November 25, 2008 10:55AM


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.