Wednesday, March 16, 2016

API to Delete User Table Rows



DECLARE
   CURSOR c1
   IS
      SELECT pur.*
        FROM pay_user_tables put, pay_user_rows_f pur
       WHERE     put.user_table_id = pur.user_table_id
             AND put.business_group_id = 10665
             AND TRUNC (SYSDATE) BETWEEN pur.effective_start_date
                                     AND pur.effective_end_date
             AND put.user_table_name = 'TABLE_NAME';          

   l_effective_start_date   DATE;
   l_effective_end_date     DATE;
BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         l_effective_start_date := NULL;
         l_effective_end_date := NULL;


         pay_user_row_api.delete_user_row (
            p_validate                      => FALSE,
            p_effective_date                => SYSDATE,
            p_datetrack_update_mode         => 'ZAP',
            p_user_row_id                   => i.user_row_id,
            p_object_version_number         => i.object_version_number,
            p_disable_range_overlap_check   => FALSE,
            p_effective_start_date          => l_effective_start_date,
            p_effective_end_date            => l_effective_end_date);

         COMMIT;

         DBMS_OUTPUT.put_line (i.user_row_id || ' has been deleted !!!');
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (
               i.user_row_id || ' Deletion Failed --> ' || SQLERRM);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (' Main Exception --> ' || SQLERRM);
END;

No comments:

Post a Comment