delimiter //
DROP PROCEDURE IF EXISTS p11;
CREATE PROCEDURE p11 (transdt varchar(25))
BEGIN
DECLARE cur_id CHAR(40);
DECLARE cur_tm CHAR(128);
DECLARE done INT ;
DECLARE cursor_test CURSOR FOR SELECT mchnt_order_id,trans_tm FROM tb where trans_dt=transdt;
DECLARE CONTINUE HANDLER for not FOUND set done=1;
OPEN cursor_test;
posLoop: LOOP
FETCH cursor_test INTO cur_id,cur_tm;
IF done=1 THEN
LEAVE posLoop;
END IF;
select cur_id,cur_tm;
END LOOP posLoop;
close cursor_test;
end;//
游标查询
最新推荐文章于 2023-09-12 15:40:54 发布