存盤程序:begin
#定義變數
declare check_id int;
declare check_year int;
declare check_month int;
declare check_day int;
declare check_In time;
declare check_Out time;
declare student_Id int;
#設定遍歷結束條件
declare flag int default 0;
#定義游標
declare check_info cursor for
select * from t_check where student_id=studentId and month=select_month;
declare continue handler for not found set flag=1;
#打開游標
open check_info;
#設定回圈跳出點
read_loop:Loop
#遍歷游標,取值
fetch check_info into check_id,check_year,check_month,check_day,check_In,check_Out,student_Id;
#無資料可遍歷是退出回圈
if flag =1 then
leave read_loop;
end if;
#自己的實務操作
insert into t_check_test
values(check_id,check_year,check_month,check_day,check_In,check_Out,student_Id);
#結束回圈
END Loop;
#關閉游標
close check_info;
#事務提交
commit;
end
表t_check:

t_check 表結構:

運行成功:


但是新表沒資料:

新表結構:
uj5u.com熱心網友回復:
你看看從原表里根據傳進的引數值,能查出結果嗎?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/28139.html
標籤:開發
