Quelque chose comme ça...
CREATE OR REPLACE
FUNCTION Fn_Display(p_empId IN VARCHAR2)
RETURN VARCHAR2
IS
empName VARCHAR2(100);
BEGIN
BEGIN
SELECT UPPER(first_name || ' ' || last_name)
INTO empName
FROM Employees
WHERE employee_id = p_empId;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE NO_DATA_FOUND
END;
RETURN empName;
END Fn_Display;
Vous pouvez appeler cette fonction où vous voulez. voici un exemple...
DECLARE
empId VARCHAR2(100);
empName VARCHAR2(100);
BEGIN
empId := &ENTER_EMPLOYEE_ID;
empName := Fn_Display(empId);
DBMS_OUTPUT.PUT_LINE('Employee Name: '||empName);
END;