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