mysql存儲過程

cursor遊標應用

select * from tbl_student0101;

drop procedure if exists crt_std;
delimiter //
create procedure crt_std()
BEGIN
	declare std_nm char(20);
	declare std_age int;
	declare std_tel char(11);
	declare std_cur cursor for select name, age, tel from tbl_student0101;
	open std_cur;
	LOOP
		fetch std_cur into std_nm, std_age, std_tel;
		select std_nm, std_age, std_tel;
	END LOOP;
	close std_cur;
END;
//
DELIMITER  ;
call crt_std();

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章