游标查询

it2023-08-15  69

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;//

最新回复(0)