之前碰到在Navicat环境下的mysql语句查询和mysql过程执行结果不一致的情况,如果碰到这种问题,请考虑数据table的数据问题,我在遇到这个问题后,逐个删除了测试数据,后测试正常。下面是调试通过的procudure,贴上来,以享后来人 :)
BEGIN
DECLARE c_storename varchar(20);
Declare c_amount double DEFAULT 0;
DECLARE c_done INT DEFAULT 0;
declare c_count int default 0;
-- 读取指定日期的店铺号
declare c_cur cursor for select storename,salemount from saletemp
where storename = storename AND riqi= sriqi;
DECLARE CONTINUE handler for NOT FOUND set c_done = 1;
open c_cur;
tip:LOOP
fetch c_cur into c_storename,c_amount;
if c_done =1 THEN
leave tip;
end if;
select c_storename,c_amount,c_done;
end LOOP tip;
close c_cur;
END