Press "Enter" to skip to content

How to Create Program Unit in Oracle Forms?

In Oracle Forms, you can create 4 types of the program through Program Unit. These 4 types are Procedures, Functions, Package Spec and the Package Body. In this article, I am giving an example to create a Function using the program unit in Oracle Forms.

Follow These Steps to Create a Function Using Program Unit in Oracle Forms.

  1. In the Oracle Form’s object navigator, click on the Program Units node and click on the + icon to create a new program unit.
  2. A New Program Unit window will appear, select the Function radio button and specify a function name in the Name field and click on the OK button.
  3. A function template window will appear. As shown in the below example.

create program unit in oracle forms

There you need to write the complete program for the function and then compile it and save. For example, you want to return salary for the specified employee number, which is being passed as a parameter to the function. The following is an example of this.

FUNCTION Get_Salary (p_empno emp.empno%type) RETURN number IS
    n_sal number;
BEGIN

   Select sal into n_sal from emp
      where empno = p_empno;

    Return n_sal;

END;

See also: