Monday, January 19, 2015

API to Delete Retro Entries - PAY_RETRO_ENTRIES

DECLARE
   CURSOR c1
   IS
      SELECT pra.retro_assignment_id, pre.owner_type, pre.element_entry_id
        FROM pay_retro_assignments pra, pay_retro_entries pre
       WHERE assignment_id = 61
             AND pra.retro_assignment_id = pre.retro_assignment_id
             AND (SELECT hl.meaning
                    FROM hr_lookups hl
                   WHERE lookup_type = 'ADVANCE_RETRO_STATUS'
                         AND hl.lookup_code = pra.approval_status) =
                    'Deferred';
BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         pay_retro_status_internal.
          delete_retro_entry (
            p_retro_assignment_id   => i.retro_assignment_id,
            p_element_entry_id      => i.element_entry_id,
            p_owner_type            => i.owner_type);

         COMMIT;
         DBMS_OUTPUT.
          put_line (i.retro_assignment_id || ' --> has been Deleted !!!');
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line (
                  'Inner Exception: '
               || SQLERRM
               || ' - '
               || i.retro_assignment_id);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      NULL;

END;

No comments:

Post a Comment