DECLARE
FUNCTION Dept_name
(department_id IN NUMBER)
RETURN departments.department_name%TYPE
IS
department_name departments.department_name%TYPE;
BEGIN
-- DEPT_NAME.department_name specifies the local variable
-- instead of the table column
SELECT department_name
INTO dept_name.department_name
FROM departments
WHERE department_id = Dept_name.department_id;
RETURN department_name;
END;
BEGIN
FOR item IN (SELECT department_id
FROM departments)
LOOP
dbms_output.Put_line('Department: '
||Dept_name(item.department_id));
END LOOP;
END;
/
Using a Subprogram Name for Name Resolution
0 comments:
Post a Comment