Difference Between PARAMETERS and GLOBAL Variables in Oracle Forms

When developing Oracle Forms applications, managing data across different program units, forms, or triggers is an essential task. Two commonly used mechanisms for handling such requirements are PARAMETERS and GLOBAL variables. Although both allow you to share and manage data, they are quite different in terms of scope, usage, and behavior.

This article explains the key differences between PARAMETERS and GLOBAL variables in Oracle Forms, how each works, and when to use them with clear examples.


Understanding PARAMETERS in Oracle Forms

PARAMETERS in Oracle Forms are placeholders that allow you to pass values from one form to another or between the form and the database. They are similar to function or procedure parameters in PL/SQL, but they work specifically within Oracle Forms.

Key Characteristics of PARAMETERS:

  • Defined in the Form Builder under the Parameters node in the Object Navigator.
  • Temporary variables whose values exist only while the form is active.
  • Used to pass data when opening a new form using the CALL_FORM, OPEN_FORM, or NEW_FORM built-ins.
  • Data type can be CHAR, NUMBER, or DATE.
  • Must be explicitly created before you can assign or retrieve values.
  • Values are automatically destroyed when the form is closed.

Example of PARAMETERS:

Suppose you want to pass an Employee ID from Form A to Form B.

In Form B (define a parameter):

  • Create a parameter named P_EMPID of type NUMBER.

In Form A (calling Form B):

DECLARE
   pl_id   ParamList;
BEGIN
   pl_id := Create_Parameter_List('emp_pl');
   Add_Parameter(pl_id, 'P_EMPID', TEXT_PARAMETER, :EMP.EMPLOYEE_ID);
   CALL_FORM('form_b', NO_HIDE, DO_REPLACE, QUERY_ONLY, pl_id);
END;

Here, the Employee ID is passed to Form B through the parameter.


Understanding GLOBAL Variables in Oracle Forms

GLOBAL variables are memory-based variables that can be created dynamically and used across multiple forms within the same Oracle Forms session.

Key Characteristics of GLOBAL Variables:

  • Defined dynamically using the built-in NAME_IN and COPY procedures.
  • Exist as string variables only (VARCHAR2 up to 255 characters).
  • Accessible from any form that is open in the same session.
  • Do not require explicit declaration in the Form Builder.
  • Must be cleared manually using ERASE after use.
  • Remain in memory until erased or until the session ends.

Example of GLOBAL Variables:

Suppose you want to share a Department ID across multiple forms.

In Form A:

COPY(:EMP.DEPT_ID, 'GLOBAL.G_DEPT');

In Form B:

:DEPT_BLOCK.DEPT_ID := NAME_IN('GLOBAL.G_DEPT');

Here, the Department ID is stored in a global variable and later retrieved in another form.


Key Differences Between PARAMETERS and GLOBAL Variables

FeaturePARAMETERSGLOBAL Variables
DefinitionDefined in Form Builder before useCreated dynamically at runtime
Data TypeCHAR, NUMBER, DATEOnly VARCHAR2 (string) up to 255 chars
ScopeSpecific to the form they are defined inAccessible across multiple forms in the same session
PersistenceExist only until the form is closedExist until erased or session ends
Use CasePassing values when calling another formStoring and sharing values across forms at runtime
DeclarationMust be predefined in the Object NavigatorNo need to declare, created dynamically
ClearingAutomatically cleared when the form closesMust be cleared manually with ERASE
PerformanceMore efficient for passing valuesLess efficient if used excessively due to memory use

When to Use PARAMETERS

  • When you want to pass specific values between forms at the time of form call.
  • When data types like DATE or NUMBER are needed (since global variables only support strings).
  • When you want automatic cleanup after form closure.
  • Best for structured and controlled data transfer.

When to Use GLOBAL Variables

  • When values need to be shared across multiple forms during the session.
  • For temporary storage of small text values like user IDs, status flags, or configuration options.
  • When you want to avoid pre-defining variables in the Form Builder.
  • Suitable for dynamic and flexible runtime data sharing.

Best Practices

  1. Use PARAMETERS for formal data passing
    They are safer, type-specific, and automatically cleaned up when the form closes.
  2. Use GLOBAL variables sparingly
    Since they remain in memory, overuse may cause performance issues or make debugging harder.
  3. Clear GLOBAL variables after use
    Always ERASE('GLOBAL.variable_name') once you no longer need them.
  4. Combine both approaches
    In complex applications, you may use PARAMETERS for structured communication and GLOBALs for lightweight session-level flags.

Conclusion

Both PARAMETERS and GLOBAL variables in Oracle Forms serve the purpose of sharing data, but they work differently. PARAMETERS are best for structured, type-specific, and temporary communication between forms, while GLOBAL variables provide a flexible way to share string values across multiple forms during a session. Understanding when to use each ensures cleaner, more maintainable, and efficient Oracle Forms applications.

Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 25+ years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments