DECLARE
CURSOR c1
IS
SELECT *
FROM (
SELECT transaction_id,
process_name,
item_type,
item_key,
transaction_effective_date
FROM HR_API_TRANSACTIONS
WHERE SELECTED_PERSON_ID
IN (SELECT PERSON_ID FROM PER_PEOPLE_X
WHERE EMPLOYEE_NUMBER IN
('12345'
))
AND STATUS = 'Y'
AND CREATION_DATE NOT LIKE SYSDATE -1
AND ITEM_KEY = '3573'
AND ITEM_TYPE = 'HRSSA'
ORDER BY CREATION_DATE DESC
);
l_cancel_workflow VARCHAR2 (1) := 'N';
BEGIN
FOR i IN c1
-- Block to Cancel Workflow
LOOP
l_cancel_workflow := 'N';
BEGIN
wf_engine.
abortprocess (itemtype => i.item_type,
itemkey => i.item_key,
process => i.process_name);
COMMIT;
l_cancel_workflow := 'Y';
DBMS_OUTPUT.
put_line ('Item Key has been Aborted/Cancelled: ' || i.item_key);
EXCEPTION
WHEN OTHERS
THEN
l_cancel_workflow := 'N';
DBMS_OUTPUT.
put_line (
'Cancel Workflow Exception: ' || SQLERRM || '- ' || i.item_key);
END;
IF l_cancel_workflow = 'Y'
THEN
-- Block to Purge Notification
BEGIN
wf_purge.total (itemtype => i.item_type, itemkey => i.item_key);
DBMS_OUTPUT.put_line ('Notification Purged : ' || i.item_key);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.
put_line (
'Purge Notification Exception: '
|| SQLERRM
|| '- '
|| i.item_key);
END;
-- Block to Rollback Transaction
BEGIN
hr_transaction_api.rollback_transaction (i.transaction_id);
DBMS_OUTPUT.
put_line ('Transaction Rolled Back : ' || i.transaction_id);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.
put_line (
'Purge Notification Exception: '
|| SQLERRM
|| '- '
|| i.item_key);
END;
END IF;
END LOOP;
END;
No comments:
Post a Comment