CREATE OR REPLACE PROCEDURE SP_CUSTCNT
AS
POSno_rec char(3);
DPTcd_rec char(4);
CUSTcnt_rec number(9);
BEGIN
declare
cursor cur_custcnt is select sslslgf_posno as pos_no,SSLSLGF_DPTCD as dptcd,nvl(sum(sslslgf_sign),0) as ctcount from (select distinct SSLSLGF_DPTCD,sslslgf_posno,sslslgf_flowno,sslslgf_sign from sslsl_goodsflow_his) group by sslslgf_posno,SSLSLGF_DPTCD;
open cur_custcnt;
loop
exit where cur_custcnt%notfound;
fetch cur_custcnt into POSno_rec,DPTcd_rec,CUSTcnt_rec;
update sslslc_regdpt set sslcdpt_custcnt= CUSTcnt_rec where sslcdpt_regcd=POSno_rec and sslcdpt_dptcd=DPTcd_rec;
end loop;
close cur_custcnt;
END SP_CUSTCNT 这个会报个错(S224) Expecting: statement_terminator BEGIN CASE DECLARE END IDENTIFIER IF LOOP我用的toad工具来执行的
AS
POSno_rec char(3);
DPTcd_rec char(4);
CUSTcnt_rec number(9);
BEGIN
declare
cursor cur_custcnt is select sslslgf_posno as pos_no,SSLSLGF_DPTCD as dptcd,nvl(sum(sslslgf_sign),0) as ctcount from (select distinct SSLSLGF_DPTCD,sslslgf_posno,sslslgf_flowno,sslslgf_sign from sslsl_goodsflow_his) group by sslslgf_posno,SSLSLGF_DPTCD;
open cur_custcnt;
loop
exit where cur_custcnt%notfound;
fetch cur_custcnt into POSno_rec,DPTcd_rec,CUSTcnt_rec;
update sslslc_regdpt set sslcdpt_custcnt= CUSTcnt_rec where sslcdpt_regcd=POSno_rec and sslcdpt_dptcd=DPTcd_rec;
end loop;
close cur_custcnt;
END SP_CUSTCNT 这个会报个错(S224) Expecting: statement_terminator BEGIN CASE DECLARE END IDENTIFIER IF LOOP我用的toad工具来执行的
AS
POSno_rec char(3);
DPTcd_rec char(4);
CUSTcnt_rec number(9); cursor cur_custcnt is select sslslgf_posno as pos_no,SSLSLGF_DPTCD as dptcd,nvl(sum(sslslgf_sign),0) as ctcount from (select distinct SSLSLGF_DPTCD,sslslgf_posno,sslslgf_flowno,sslslgf_sign from sslsl_goodsflow_his) group by sslslgf_posno,SSLSLGF_DPTCD;
BEGIN
open cur_custcnt;
loop
exit where cur_custcnt%notfound;
fetch cur_custcnt into POSno_rec,DPTcd_rec,CUSTcnt_rec;
update sslslc_regdpt set sslcdpt_custcnt= CUSTcnt_rec where sslcdpt_regcd=POSno_rec and sslcdpt_dptcd=DPTcd_rec;
end loop;
close cur_custcnt;
END SP_CUSTCNT ;改成上面的就可以了