Thursday, 12 January 2012

CURSOR_UPDATE

/* Formatted on 1/12/2012 2:54:53 PM (QP5 v5.115.810.9015) */
DECLARE
   CURSOR c1
   IS
      SELECT   TMP.*, map.h_document_number, map.operating_unit r12ou
        FROM   XX_AP_CHECKS_11I_R12 map, XX_CHECK_DATA_TEMP TMP
       WHERE   map.H_DOCUMENT_NUMBER = TMP.R12_CHECK_NUMBER;
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,
               R12_BANK_ACCT_NAME = I.H_BANK_ACCT_NAME,
               R12_CURRENCY_CODE = I.H_CURRENCY_CODE
       WHERE   H_DOCUMENT_NUMBER = I.R12_CHECK_NUMBER
               AND OPERATING_UNIT = DECODE (I.R12_OPERATING_UNIT,
                                            'APIL - HO - 10',
                                            'BILT POWER LTD. HO',
                                            'APIL - SHREE GOPAL UNIT - 30',
                                            'BILT POWER LTD,SGU',
                                            'APIL - SEWA UNIT - 40',
                                            'BILT POWER LTD,SEW',
                                            'APIL - BWN - 50',
                                            'BILT POWER LTD,BWN',
                                            ' APIL - BPU UNIT - 20',
                                            'BILT POWER LTD,BPU');
   END LOOP;
END;

No comments:

Post a Comment