--------根据STOCK_LOT_STORAGESPACES 生成其他五大库存。只需调STOCK_LOT_STORAGESPACES这个表就行
BEGIN
FOR C IN (SELECT DISTINCT A.SPID, A.YZID
FROM STOCK_LOT_STORAGESPACES A
WHERE spid='SPH00010308') LOOP
DELETE FROM STOCK
WHERE SPID = C.SPID
AND YZID = C.YZID;
INSERT INTO STOCK
(SPID,
SL_KC,
SL_KCK,
SL_CKYFP,
SL_RKYFP,
SL_FHGPCKYFP,
SL_FHGPRKYFP,
YZID)
SELECT SPID,
SUM(SL_KC) SL_KC,
SUM(SL_KCK) SL_KCK,
SUM(SL_CKYFP) SL_CKYFP,
SUM(SL_RKYFP) SL_RKYFP,
SUM(SL_FHGPCKYFP) SL_FHGPCKYFP,
SUM(SL_FHGPRKYFP) SL_FHGPRKYFP,
YZID
FROM STOCK_LOT_STORAGESPACES --HAVING SUM(SL_KC)>0
WHERE SPID = C.SPID
AND YZID = C.YZID
GROUP BY SPID, YZID;
END LOOP;
END;
/