API to Create Organization Manager
/* Formatted on 2017/10/02 12:34 (Formatter Plus v4.8.8) */
DECLARE
v_org_information_id NUMBER;
v_object_version_number NUMBER;
v_warning BOOLEAN;
l_start_date DATE;
l_org_id NUMBER;
l_person_id NUMBER;
l_error VARCHAR2 (2500);
CURSOR cur_ee
IS
SELECT *
FROM xxkq_org_manager_api_stg
WHERE status IS NULL AND sno <= 1;
BEGIN
FOR c1_ee_rec IN cur_ee
LOOP
BEGIN
SELECT papf.person_id, paaf.effective_start_date
INTO l_person_id, l_start_date
FROM per_all_people_f papf, per_all_assignments_f paaf
WHERE 1 = 1
AND papf.person_id = paaf.person_id
AND papf.employee_number = c1_ee_rec.org_owner_staff_no
AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
AND paaf.effective_end_date;
EXCEPTION
WHEN OTHERS
THEN
l_error := 'Invalid Emp Details' || SQLERRM;
END;
BEGIN
SELECT organization_id
INTO l_org_id
FROM hr_all_organization_units
WHERE NAME = TRIM (c1_ee_rec.NAME);
EXCEPTION
WHEN OTHERS
THEN
l_error := 'Invalid Org Details' || SQLERRM;
END;
IF l_error IS NULL
THEN
BEGIN
hr_organization_api.create_org_manager
(p_validate => FALSE,
p_effective_date => l_start_date,
p_organization_id => l_org_id,
p_org_info_type_code => 'Organization Name Alias',
p_org_information2 => l_person_id,
p_org_information3 => TO_CHAR
(l_start_date,
'YYYY/MM/DD HH24:MI:SS'
),
p_org_information4 => '4712/12/31 00:00:00',
p_org_information_id => v_org_information_id,
p_object_version_number => v_object_version_number,
p_warning => v_warning
);
UPDATE xxkq_org_manager_api_stg
SET status = 'S'
WHERE sno = c1_ee_rec.sno;
EXCEPTION
WHEN OTHERS
THEN
l_error := SQLERRM;
UPDATE xxkq_org_manager_api_stg
SET status = 'E',
error_msg = l_error
WHERE sno = c1_ee_rec.sno;
END;
ELSE
UPDATE xxkq_org_manager_api_stg
SET status = 'E',
error_msg = l_error
WHERE sno = c1_ee_rec.sno;
END IF;
END LOOP;
COMMIT;
END;
No comments:
Post a Comment