The ERRBUFF can be returned with any message.
The RETCODE can be returned with one of three values:
0 -- Success
1 -- Warning
2 -- Error
----------------------------------------------------------
-- Package Specification
----------------------------------------------------------
CREATE OR REPLACE PACKAGE apps.emp_test_pkg
IS
FUNCTION emp_name (
errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY VARCHAR2,
p_emp_number IN NUMBER)
RETURN VARCHAR2;
END emp_test_pkg;
/
----------------------------------------------------------
-- Package Body
----------------------------------------------------------
CREATE OR REPLACE PACKAGE BODY apps.emp_test_pkg
IS
FUNCTION emp_name (
errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY VARCHAR2,
p_emp_number IN NUMBER)
RETURN VARCHAR2
IS
lv_emp_name VARCHAR2(300) DEFAULT NULL;
BEGIN
SELECT (papf.first_name || ' ' || papf.last_name)
INTO lv_emp_name
FROM per_all_people_f papf
WHERE 1=1
AND papf.employee_number = p_emp_number;
RETURN (lv_emp_name);
EXCEPTION
WHEN NO_DATA_FOUND THEN
errbuff := 'No employee found for ' || p_emp_number;
retcode := '1'; -- warning
fnd_file.put_line(fnd_file.log, errbuff);
RETURN (lv_emp_name);
WHEN OTHERS THEN
errbuff := SQLERRM;
retcode := '2'; -- error
fnd_file.put_line(fnd_file.log, errbuff);
RETURN (lv_emp_name);
END emp_name;
END emp_test_pkg;
/
No comments:
Post a Comment