1drop table if exists t1; 2drop table if exists t2; 3create table t1 ( 4a int not null primary key, 5b int not null 6) engine=ndb; 7create table t2 ( 8a int not null primary key, 9b int not null 10) engine=ndb; 11insert into t1 values (1,10), (2,20), (3,30), (4, 40); 12create procedure test_cursor () 13begin 14declare done int default 0; 15declare temp_a int; 16declare temp_b int; 17declare cur1 cursor for select a,b from t1; 18declare continue handler for sqlstate '02000' set done = 1; 19open cur1; 20repeat 21fetch cur1 into temp_a, temp_b; 22if not done then 23insert into t2 values (temp_a, temp_b); 24end if; 25until done end repeat; 26close cur1; 27end; 28// 29select * from t2 order by a; 30a b 31call test_cursor(); 32select * from t2 order by a; 33a b 341 10 352 20 363 30 374 40 38drop procedure test_cursor; 39drop table t1,t2; 40end of 5.1 tests 41