Monday, 31 October 2011

PO_DELIVERY_TERMS_UPD_QRY

/* Formatted on 28-09-2011 11:57:57 (QP5 v5.115.810.9015) */
DECLARE
   CURSOR c1
   IS
      SELECT   po.FREIGHT_TERMS_LOOKUP_CODE,
               po.SHIP_VIA_LOOKUP_CODE,
               po.FOB_LOOKUP_CODE,
               map.OLD_R12_TERMID,
               map.TERM_NAME,
               map.NEW_CARRIER,
               map.NEW_FREIGHT,
               map.DT_LOOKUP_CODE,
               map.po_no,
               po.org_id,
               map.NEW_R12_TERM_NAME,
               map.NEW_R12_TERM_ID,
               po.terms_id
        FROM   xx_backlog_po_updation map, PO_HEADERS_ALL po
       WHERE   map.po_no = po.segment1 and map.org_id=po.org_id;                  --AND po.org_id = 90;
BEGIN
   FOR i IN c1
   LOOP
      UPDATE   PO_HEADERS_ALL
         SET   --FREIGHT_TERMS_LOOKUP_CODE = i.NEW_FREIGHT,
               --SHIP_VIA_LOOKUP_CODE = i.NEW_CARRIER,
               --FOB_LOOKUP_CODE = i.DT_LOOKUP_CODE,
               TERMS_ID = i.NEW_R12_TERM_ID
       WHERE   segment1 = i.po_no AND org_id = i.org_id;
   END LOOP;
END;

No comments:

Post a Comment