Thursday, 12 January 2012

CURSOR_USING_UPDATE

/* Formatted on 1/12/2012 12:07:12 AM (QP5 v5.115.810.9015) */
DECLARE
   CURSOR c1
   IS
      SELECT   TMP.*, map.h_document_number, map.r12_operating_unit r12ou
        FROM   XX_AP_CHECKS_11I_R12 map, XX_CHECK_DATA_TEMP TMP
       WHERE   map.H_DOCUMENT_NUMBER = TMP.R12_CHECK_NUMBER
               AND MAP.R12_OPERATING_UNIT = TMP.R12_OPERATING_UNIT;
BEGIN
   FOR I IN c1
   LOOP
      UPDATE   XX_AP_CHECKS_11I_R12
         SET   R12_OPERATING_UNIT = I.R12_OPERATING_UNIT,
               R12_CHECK_ID = I.R12_CHECK_ID,
               R12_VENDOR_NAME = I.R12_VENDOR_NAME,
               R12_VENDOR_SITE_CODE = I.R12_VENDOR_SITE_CODE,
               R12_CHECK_NUMBER = I.R12_CHECK_NUMBER,
               R12_CHECK_DATE = I.R12H_CHECK_DATE,
               R12_CHECK_AMOUNT = I.R12_CHECK_AMOUNT,
               H_BANK_ACCT_NAME = I.H_BANK_ACCT_NAME,
               R12_CURRENCY_CODE = I.H_CURRENCY_CODE
       WHERE   H_DOCUMENT_NUMBER = I.R12_CHECK_NUMBER
               AND R12_OPERATING_UNIT = I.R12_OPERATING_UNIT;
   END LOOP;

   COMMIT;
END;

No comments:

Post a Comment