DELETE FROM DC2.OR_100 WHERE PV_USER = '676';
commit;
INSERT INTO DC2.OR_100 (PV_KEY,PV_USER,PV1,PV2,PV3,PV4,PV5,PV6,PV7)
SELECT LPAD(TO_CHAR(ROWNUM),20,0),TABLE_SELECT.* FROM (
SELECT '676'
 ,SUBSTRB(SUBSTRB( T001.BILLDate,1,4) || '/' || SUBSTRB( T001.BILLDate,5,2) || '/01',1,100) AS A001
 ,SUBSTRB(T001.CUSTCode,1,100) AS A002
 ,SUBSTRB(T002.CUSTName,1,100) AS A003
 ,SUBSTRB(T001.BILLName,1,100) AS A004
 ,SUBSTRB(TO_CHAR(T001.BILLDETAILPrice),1,100) AS A005
 ,SUBSTRB(TO_CHAR(T001.TAXPrice),1,100) AS A006
 ,SUBSTRB(TO_CHAR(T001.BILLPrice),1,100) AS A007
FROM
 ILS_SEIKYU.H_BILL@ILS_SEIKYU T001
,ILS_SEIKYU.M_CUST@ILS_SEIKYU T002
WHERE
 T001.CUSTCode=T002.CUSTCode(+)
 AND T001.BILLDate BETWEEN '20180401' AND '20190331'
ORDER BY
  SUBSTRB( T001.BILLDate,1,4) || '/' || SUBSTRB( T001.BILLDate,5,2) || '/01'
 ,T001.CUSTCode
) TABLE_SELECT
;
commit;
EXIT;


