Friday, April 5, 2019
API to update Employee Phone Number HR_PHONE_API.CREATE_OR_UPDATE_PHONE
In this post, we have given a
sample script to update the Employee phone number. This we tried in R12.2.4
instance.
API: HR_PHONE_API.CREATE_OR_UPDATE_PHONE
Tested instance: R12.2.4
Script:
set serveroutput on;DECLAREln_phone_id PER_PHONES.PHONE_ID%TYPE;ln_object_version_number PER_PHONES.OBJECT_VERSION_NUMBER%TYPE;ld_start_date DATE;ln_person_id NUMBER;lv_emp_num VARCHAR2(100);position_ NUMBER;routine_ VARCHAR2(2000);CURSOR cur_emp_dataIS-- This part can be changed with different query with staging tableSELECT 123456789 telephone_number,'EMP123456' employee_numberFROM dual;BEGINposition_ :=1200;routine_ := 'UPDATE_EMPLOYEE_PHONE_RECORD';FOR rec_emp_data IN cur_emp_dataLOOPSELECT effective_start_date,person_idINTO ld_start_date,ln_person_idFROM per_all_people_fWHERE employee_number = rec_emp_data.employee_numberAND SYSDATE BETWEEN effective_start_date AND effective_end_date;BEGINposition_ := 1210;ln_phone_id := NULL;ln_object_version_number := NULL;BEGINSELECT phone_id,object_version_numberINTO ln_phone_id,ln_object_version_numberFROM per_phonesWHERE parent_id = ln_person_idAND date_from = ld_start_date;EXCEPTIONWHEN OTHERS THENNULL;END;hr_phone_api.create_or_update_phone(p_date_from => ld_start_date,p_phone_type => 'W1',p_phone_number => rec_emp_data.telephone_number,p_parent_id => ln_person_id,p_parent_table => 'PER_ALL_PEOPLE_F',p_effective_date => SYSDATE,p_phone_id => ln_phone_id,p_object_version_number => ln_object_version_number);position_ :=1220;DBMS_OUTPUT.PUT_LINE('ln_person_id : '||ln_person_id );DBMS_OUTPUT.PUT_LINE('ln_phone_id : '||ln_phone_id );DBMS_OUTPUT.PUT_LINE('rec_emp_data.telephone_number : '||rec_emp_data.telephone_number );COMMIT;DBMS_OUTPUT.PUT_LINE('API : create_or_update_phone successfull for employee : '||rec_emp_data.employee_number);position_ :=1230;EXCEPTIONWHEN OTHERS THENDBMS_OUTPUT.PUT_LINE('Others Error in API : create_or_update_phone for employee : ' ||rec_emp_data.employee_number|| ' SQLERRM: ' || SQLERRM);END;END LOOP;position_ :=1250;EXCEPTIONWHEN OTHERS THENDBMS_OUTPUT.PUT_LINE('Others Error in update_employee_phone_number on position_ ' ||position_ || '. SQLERRM: ' || SQLERRM);ROLLBACK;END;
Hope this Helps!!
Do you think this Article is useful?
Subscribe to:
Post Comments (Atom)
Disclaimer
The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.
0 Responses to “API to update Employee Phone Number HR_PHONE_API.CREATE_OR_UPDATE_PHONE”
Post a Comment