如何使用批量收集或在以下代码中插入。我有1700多个记录。我必须尽量减少执行时间
FOR LP IN
( SELECT * FROM GLOBAL_TEMP )
LOOP
BEGIN
XYZ(LP.ID,CID,TO_DATE( FROM_DATE,'DD/MM/YYYY'),TO_DATE(TO_DATE,'DD/MM/YYYY'),'AA','TRUE','TRUE',A,B,C,D,E,F);
XYZ(LP.ID,IP_COMPANY_ID,TO_DATE( IP_FROM_DATE,'DD/MM/YYYY'),TO_DATE(TO_DATE,'DD/MM/YYYY'),'BB','TRUE','TRUE',A,B,C,D,E,F);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -1436 THEN
DBMS_OUTPUT.put_line(LP.ID || 'IN EXCEPTION');
NULL;
END IF;
END;
END LOOP;
INSERT INTO GLOBAL_TEMP
SELECT * FROM
(
SELECT DISTINCT
ID
,TT.NAME,TT.PTID
,NVL(CASE WHEN VAR1 = 'AA' THEN _BAL ELSE 0 END,0), NVL(CASE WHEN VAR1= 'BB' THEN BAL ELSE 0 END,0)
,NVL(CASE WHEN VAR2 ='AA' THEN OBAL ELSE 0 END ,0) , NVL(CASE WHEN VAR2 ='BB' THEN _BAL ELSE 0 END,0)
,'TTT',M,N,BSA.P_NAME,BSA.P_LEVEL +1
FROM LMN TT
INNER JOIN GLOBAL_TEMP BSA ON BSA.ID = TT.ID
WHERE USER_ID=ID AND ID IN(SELECT ID FROM GLOBA_TEMP)
CONNECT BY NOCYCLE PRIOR ID = PID
ORDER BY TT.NAME
)
OPEN CUR FOR
SELECT ID,V,I,A,B,C,D,E,F,G,H,
CONNECT_BY_ISCYCLE "Cycle",K, SYS_CONNECT_BY_PATH(Id, '/') "Path" FROM GLOBAL_TEMP
START WITH level=1
CONNECT BY NOCYCLE PRIOR ID = PID
ORDER SIBLINGS BY LEVEL,ID,J;