CREATE PROCEDURE proc_wl_jhrk_js
(
@rkdh varchar(10),
@yhbh varchar(10)
)
AS
delete from up_zbkcb where yhbh = @yhbh
insert up_zbkcb (cpbh,kcsl,yhbh)
select cpbh,sum(sl),@yhbh from wl_cprk_list where rkdh = @rkdh
group by cpbh
update shop_list set lks = isnull(lks,0)+ a.sl
from wl_cprk_list a,shop_list b where a.rkdh = @rkdh and a.cgdh = b.cgdh and a.cpbh = b.cpbh
update zbkcb
set zbkcb.kcsl = isnull(zbkcb.kcsl,0) + up_zbkcb.kcsl
from up_zbkcb,zbkcb where up_zbkcb.cpbh = zbkcb.cpbh and kw = '01' and kb = 'A' and up_zbkcb.yhbh = @yhbh
return 0