Bellow是我的代码定义内部存储过程,调试查询选择有结果但是调试代码SELECT order_id返回NULL结果并且没有行添加到table3。 请帮忙
BEGIN
declare done INTEGER DEFAULT 0;
declare id int;
declare order_id int;
declare amount DECIMAL;
declare shipping_date datetime;
declare code VARCHAR(20);
declare cur1 cursor for
select p.* from (SELECT id,order_id,amount,shipping_date from order_detail od where
od.status in (0)
and od.shipping_date <DATE_ADD(Now(), INTERVAL -10 DAY))p
join `order` o on o.id =p.order_id and o.status in (0,11)
and o.country = 'US' and o.is_dvg = 0 ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
DROP TABLE IF EXISTS table3;
CREATE TABLE table3 (id int,order_id int,amount DECIMAL,shipping_date datetime);
SELECT done;
open cur1;
igmLoop: loop
fetch cur1 into id,order_id,amount,shipping_date;
SELECT order_id;
if done = 1 then leave igmLoop; end if;
INSERT INTO table3 VALUES (id,order_id,amount,shipping_date);
end loop igmLoop;
close cur1;
SELECT * from table3;
END