Tuesday, April 18, 2017

Merge Statement

MERGE INTO CMG_PPA_SUBSIDIARY_LEDGER_TBL  hra
USING (
     select AMOUNT,CMG_PPA_SUB_LEDGER_ID SUB from
       CMG_PPA_SUBSIDIARY_LEDGER_TBL
         where vendor_id=143) main1
ON (hra.CMG_PPA_SUB_LEDGER_ID =main1.SUB)
WHEN MATCHED THEN
UPDATE SET
hra.VENDOR_func_amount = main1.AMOUNT
WHEN NOT MATCHED THEN
INSERT ( hra.VENDOR_func_amount) VALUES (main1.AMOUNT);
Commit;


MERGE INTO CMG_PPA_REMITTANCES_DETAIL_TBL  hra
USING (
     select AMOUNT,REMITTANCE_DETAIL_ID RDI from
            CMG_PPA_REMITTANCES_DETAIL_TBL
         where issue_dim_id in (select issue_dim_id from CMGPPA.CMG_PPA_ISSUE_DIM_TBL where ISS_PUB_ID=143))main1
ON (hra.REMITTANCE_DETAIL_ID=main1.RDI)
WHEN MATCHED THEN
UPDATE SET
hra.CMG_FUNC_AMOUNT = main1.AMOUNT
WHEN NOT MATCHED THEN
INSERT ( hra.CMG_

No comments:

Post a Comment