1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
PROCEDURE "RMPL_CRC_MENS_CRC4" AS
BEGIN
DELETE FROM APS_STAT_CRC_MENS;
INSERT INTO APS_STAT_CRC_MENS (AS_SITE_ID,
AS_SERVICE_ID,
AS_REGION_ID,
AS_MARQUE_ID,
AS_VDN_TYPE_ID,
AS_YEAR,
AS_MONTH,
AS_NB_TRAITE)
SELECT AAS_SITE_ID,
SERVICE_ID,
REGION_ID,
MARQUE_ID,
VDN_TYPE,
TO_CHAR(DELIVERED_CALL_DATE, 'YYYY'),
TO_CHAR(DELIVERED_CALL_DATE, 'MM'),
count(*)
FROM APS_STAT_APPELS INNER JOIN APS_AGENT_SITE ON (IC_AGENT_ID = AAS_EMPLOYEE_ID)
WHERE VDN_TYPE = 'E'
AND VDN_ROUTE2 IS NOT NULL
AND IC_AGENT_ID IS NOT NULL
AND TRUNC(DELIVERED_CALL_DATE, 'YYYYMM') < TRUNC(SYSDATE, 'YYYYMM')
GROUP BY TRUNC(DELIVERED_CALL_DATE, 'YYYY'), TRUNC(DELIVERED_CALL_DATE, 'MM'), AAS_SITE_ID, SERVICE_ID, REGION_ID, MARQUE_ID, VDN_TYPE
ORDER BY TRUNC(DELIVERED_CALL_DATE), TRUNC(DELIVERED_CALL_DATE), AAS_SITE_ID, SERVICE_ID, REGION_ID, MARQUE_ID, VDN_TYPE;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.PUT_LINE( 'Code erreur : ' || to_char( SQLCODE ));
dbms_output.PUT_LINE( 'libellé erreur : ' || to_char( SQLERRM ));
END; |
Partager