How to Use FIND_FORM and GO_FORM in Oracle Forms

In multi-form Oracle Forms applications, developers often need to manage navigation between different forms that are already open. Instead of repeatedly reopening forms, Oracle provides built-ins like FIND_FORM and GO_FORM. These built-ins allow you to check whether a form is active and switch focus to it when required.

This tutorial explains how to use FIND_FORM and GO_FORM, their syntax, examples, and best practices.


FIND_FORM in Oracle Forms

The FIND_FORM built-in is used to check whether a specific form is currently open. It returns the form ID if the form is active, otherwise it returns NULL. This is useful when you need to determine whether a form is loaded before performing an action such as navigating or closing it.

Key Points

  • Returns the unique form ID of the specified form.
  • Returns NULL if the form is not open.
  • Useful for conditional checks before navigation.

Syntax

form_id := FIND_FORM(form_name);

Example

DECLARE
   v_form_id FORM_MODULE;
BEGIN
   v_form_id := FIND_FORM('EMPLOYEE_FORM');
   IF v_form_id IS NOT NULL THEN
      MESSAGE('Employee form is already open.');
   ELSE
      OPEN_FORM('EMPLOYEE_FORM');
   END IF;
END;

In this example, the code checks if EMPLOYEE_FORM is already open. If not, it opens the form.


GO_FORM in Oracle Forms

The GO_FORM built-in is used to navigate to a form that is already open. It transfers control to the specified form, bringing it to the foreground for the user to work on.

Key Points

  • Switches focus to an open form.
  • Requires that the target form is already open.
  • If the form is not open, it will raise an error.

Syntax

GO_FORM(form_name);

Example

BEGIN
   GO_FORM('DEPARTMENT_FORM');
END;

This command switches focus to the DEPARTMENT_FORM if it is already open.


Using FIND_FORM and GO_FORM Together

The most common use case is to combine FIND_FORM and GO_FORM. This allows you to check whether a form is open and, if so, transfer focus to it. If it is not open, you can decide whether to open it.

Example: Safe Navigation Between Forms

DECLARE
   v_form_id FORM_MODULE;
BEGIN
   v_form_id := FIND_FORM('DEPARTMENT_FORM');
   IF v_form_id IS NOT NULL THEN
      GO_FORM('DEPARTMENT_FORM');
   ELSE
      OPEN_FORM('DEPARTMENT_FORM');
   END IF;
END;

Here, the code first checks if DEPARTMENT_FORM is open. If it is, the user is taken directly to it using GO_FORM. If not, it is opened with OPEN_FORM.


Practical Scenarios

Scenario 1: Preventing Duplicate Form Instances

If you do not want users to open multiple instances of the same form:

IF FIND_FORM('EMPLOYEE_FORM') IS NULL THEN
   OPEN_FORM('EMPLOYEE_FORM');
ELSE
   GO_FORM('EMPLOYEE_FORM');
END IF;

Scenario 2: Switching Between Dashboard Forms

In a multi-form dashboard application, you might have different modules (e.g., Employees, Departments, Payroll). Using GO_FORM ensures that the user switches smoothly without reopening forms unnecessarily.


Best Practices

  1. Always use FIND_FORM before GO_FORM โ€“ This avoids runtime errors if the form is not open.
  2. Avoid unnecessary OPEN_FORM calls โ€“ Use FIND_FORM to check if the form is already loaded.
  3. Use GO_FORM for better user experience โ€“ It allows fast switching between forms without reloading.
  4. Close unused forms โ€“ If too many forms remain open, it can consume memory resources.
  5. Combine with navigation logic โ€“ Often, these built-ins are used inside menu items to manage navigation efficiently.

Conclusion

The FIND_FORM and GO_FORM built-ins in Oracle Forms are essential for managing navigation in multi-form applications. While FIND_FORM helps you determine whether a form is already open, GO_FORM allows you to switch focus to that form without reopening it. Using them together improves performance, prevents duplicate forms, and creates a smoother user experience. By following best practices, you can design forms that are both efficient and user-friendly.

Get more Vinish.dev tutorials on Google

See my articles more often when you search Google.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted