|
7#
楼主 |
发表于 2011-10-27 09:33:10
|
只看该作者
if (dateType='Year') then
begin
DECLARE curdeal_1 CURSOR FOR
select sum(skt43.skf610),skt57.skf772,CONCAT(YEAR(skt43.skf611)) from skt57 left join (skt43,skt42) on (skt43.skf616//所在合同=skt42.skf587//合同编号 and skt57.skf772//办事处人员编号=skt42.skf589//合同表业务员 and skt43.skf615//来自哪个合同=1 and skt43.skf611//收款时间>=dateBegin and skt43.skf611收款时间<=dateEnd) GROUP BY (CONCAT(YEAR(skt43.skf611))),skt57.skf772//办事处人员编号;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET mark=1;
open curdeal_1;
repeat
FETCH curdeal_1 into amount,Salesman,statDate;
if(mark < 1)then
if (Salesman not in ('138','132'))then
begin
INSERT INTO skt68 (SKF911,SKF909,SKF910) select tblemployee.Name,statDate,amount from tblemployee where tblemployee.ID=Salesman;
end;
end if;
end if;
UNTIL mark=1
end REPEAT;
CLOSE curdeal_1;
end;
我理解为是执行这个存储程序就会删除原有的SKT68里面的数据,然后再插入新的数据,是吗 |
|