Index | Home | Forums
Oracle PL/SQL Example 2-15 Using a Subprogram Name for Name Resolution

Example 2-15 Using a Subprogram Name for Name Resolution

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;
/


This page was created by oracleabc.com on Feb 23,2008 00:09:02
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here