Wednesday 21 March 2012

Anonymous PL/SQL Block to update records using cursors in Oracle Apps

Anonymous PL/SQL Block to update records using cursors in Oracle Apps


DECLARE
   CURSOR c1
   IS
      SELECT xxrs.shipmentline_id, xxrs.amount, jrl.tax_amount
        FROM xxcust_table xxrs, jai_rcv_lines jrl
       WHERE xxrs.shipmentline_id = jrl.shipment_line_id;


   num_total_rows   NUMBER;
BEGIN
   FOR i IN c1
   LOOP
      UPDATE jai_rcv_lines
         SET tax_amount = i.amount
       WHERE shipment_line_id = i.shipmentline_id;


      COMMIT;
      num_total_rows := c1%ROWCOUNT;
   END LOOP;


   DBMS_OUTPUT.put_line ('Total No of Rows Updated : ' || num_total_rows);
END;

No comments:

Post a Comment