Use the following information to help you determine when to use global, parameter,
or package variables. Note that with Oracle Forms 10g, for parameters, the Maximum Length property has been removed.
In previous releases, a value of up to 2000 could be specified for parameters
of datatype CHAR, but it was not enforced consistently.
In general, it was enforced only when the parameter was set or referenced
using PL/SQL bind variable notation, e.g. :PARAMETER.MY_PARAM. In Oracle Forms 10g, all parameters of datatype CHAR are limited to 4000 bytes
when set or referenced using PL/SQL bind variable notation; for other usages
no limit is imposed.
Similarly, global variables are now limited to 4000 bytes
when set or referenced using PL/SQL bind variable notation; for other usages,
no limit is imposed. Previous releases enforced a limit of 255 bytes
for all usages.
Datatype: Globals are always CHAR data. Parameters are NUMBER, CHAR, or DATE. Package variables can be any PL/SQL data type.
Creation: Globals are created the first time they are assigned.
Parameters must be named and typed at design-time, or alternately may be added to a parameter List at runtime with the Add_Parameter() Built-in.
Package variables are explicitly declared as part of a package.
Default Values: Globals must have a value programmatically assigned.
Parameters can be assigned a default value of the proper datatype at design-time.
Package variables can be assigned a default value of the proper datatype at design-time. Package variables can also be initialized with arbitrarily complex code in the initialization block of the package.
Assignment: Globals are assigned directly through PL/SQL with the bind variable notation (:GLOBAL.GLOBAL_NAME), or indirectly using the Copy() Built-in.
Parameters in the default parameter List (those created at design-time) are assigned directly through PL/SQL with the bind variable notation (:PARAMETER.PARAM_NAME), or indirectly with the Copy() Built-in. If part of a parameter List is not the default parameter List, then the Set_Parameter_Attr() Built-in is used. In addition, parameters which are declared at design-time can be supplied with values on the command line using the "PARAMNAME=Value" syntax.
Package variables are assigned directly through PL/SQL.
Scope: Global names are global to the whole runform session. Therefore, if you try to combine two forms that happen to use the same global name for different purposes, the forms will not integrate without changes.
Parameter values are local to a particular form. There is no interaction, unless a parameter is explicitly passed from one form to another. When integrating forms it is essential to ensure that they share the correct parameter names.
Package variables are qualified by the name of the package. If two packages declare the same variable name, there is no interaction between them. Integrating forms that rely on package variables for their shared global data is much more straightforward than using the other two methods, because there are no hidden subtle interactions between same-name objects.
Persistence: Globals preserve their value for the duration of the Runform session, unless explicitly erased. They are visible to all forms which get called during the session. Any modification made to a global variable in a called form is visible to any calling form and all subsequent forms in the session.
Parameters are visible only to the form in which they are declared, unless they are passed as part of a parameter List. In this case they supply incoming values for the form-level parameters declared for the called form.
The value of the parameter in the calling form is thus visible to the called form in this way. Any modification made in a called form to a parameter is not visible to the calling form. The called form gets "fed" a snapshot of the parameter values as they existed at the moment of the Call_Form(), and works with private copies of the values.
Package variables preserve their value for the duration of the Runform session. They are visible to all forms which get called during the session provided the CALL_FORM argument data_mode is set to SHARE_LIBRARY_DATA. Any modification made in a called form to a package variable is visible to any calling form and all subsequent forms in the session.
Documentation: Globals can be created anywhere in any trigger. Unless a developer is disciplined and uses some sort of methodology, globals variables can be very hard to find and document. Errors are easy to make and hard to find, since a typing error when assigning to a global simply creates a new global under the new, mistyped name.
Parameters exist as named object at the form level, can have meaningful default values, and can be documented with object comments like any other forms object.
Package variables are declared explicitly in a package and can be explicitly initialized. They can be easily documented in the PL/SQL code.
Summary: To pass values into a form from the command line, use parameters.
If you specifically need to create variables dynamically, use globals, but first consider whether a table of records would be a more efficient mechanism for storing many dynamically created values.
For all other purposes use package variables.