DECLARE
CURSOR fetch_det
IS
SELECT paaf.assignment_id,
peef.element_entry_id,
peef.object_version_number
FROM per_people_x per,
per_assignments_x paaf,
pay_element_entries_f peef
WHERE per.person_id = paaf.person_id
AND per.person_type_id IN (1126, 1127)
AND paaf.assignment_type = 'E'
AND paaf.assignment_status_type_id IN (1, 2)
AND paaf.primary_flag = 'Y'
AND peef.assignment_id = paaf.assignment_id
AND peef.element_link_id = 182
AND TRUNC (SYSDATE) BETWEEN peef.effective_start_date
AND peef.effective_end_date;
l_effective_start_date DATE := NULL;
l_effective_end_date DATE := NULL;
l_element_entry_id NUMBER := NULL;
l_delete_warning BOOLEAN;
l_err_msg VARCHAR2 (500) := NULL;
BEGIN
FOR i IN fetch_det
LOOP
BEGIN
pay_element_entry_api.delete_element_entry (
p_validate => FALSE,
p_datetrack_delete_mode => 'DELETE', -- ZAP to Purge from Database
p_effective_date => TO_DATE ('01-APR-2013'),
p_element_entry_id => i.element_entry_id,
p_object_version_number => i.object_version_number,
p_effective_start_date => l_effective_start_date,
p_effective_end_date => l_effective_end_date,
p_delete_warning => l_delete_warning
);
COMMIT;
DBMS_OUTPUT.put_line (
'Element has been deleted: ' || i.element_entry_id
);
EXCEPTION
WHEN OTHERS
THEN
l_err_msg := SQLERRM;
DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
l_err_msg := SQLERRM;
DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);
END;
I faced the following error
ReplyDeleteMain Exception: ORA-20001: HR_7220_INVALID_PRIMARY_KEY: