Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

using Global variables/parameters in D2k forms

Posted on 2003-03-24
4
Medium Priority
?
2,495 Views
Last Modified: 2007-12-19


I have created some D2k forms.  I need to initiate Global variables/parameters in calling and called forms(variable name is myvar varchar2(30)).  But I dont know how to do it.

Can any one guide me where and how to initiate the global variables/parameters,  how to retrieve the values and make use of them.

thanks

prabhu
0
Comment
Question by:srigupta
  • 3
3 Comments
 
LVL 22

Expert Comment

by:Helena Marková
ID: 8201175
Global variable can be defined everywhere in a Forms. I use them rarely. I define them in the When-New-Form-Instance trigger:
:GLOBAL.myvar := 'my_value';
The data type of the global variables is always VARCHAR2 !

This is from the on-line help - "Passing parameters to forms" topic:
When you invoke a form with the procedures OPEN_FORM, CALL_FORM, or NEW_FORM, you can pass values for form parameters from the calling form to the called form.
To pass parameter values from one form to another, each parameter and its value must be in a parameter list.  Parameter lists are internal, three-column data structures that contain the key (name), the type  (Text_Parameter or Data_Parameter) and the value of each parameter on the list.
The parameters whose values are being passed must have been defined in the called form at design time.  That is, the called form must be expecting a value for each of the parameters included in the parameter list it receives from the calling form.

You can define parameters in a form in the Object Navigator at design time and also programmatically at runtime.  The properties of a parameter include Name, Parameter Data Type, Length, and Parameter Initial Value.  Parameter lists must be created programmatically with the built-in routines CREATE_PARAMETER_LIST and ADD_PARAMETER.
Parameter values are not visible across multiple forms.  Thus, even if there is a parameter named p1 defined in both Form A and Form B, each form has a separate context, and setting the value of p1 in Form B has no effect on the value of p1 in Form A.  For this reason, parameters are useful in multiple-form applications primarily as inputs to a form when it is first invoked.

If your application requires variables whose values are visible across called forms, you should use global variables. Global variables are visible across called forms, and remain active until they are explicitly deleted with the ERASE built-in procedure, or until the session ends.

Henka
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 8201227
There are Text or Data parameters there. This is an example of using it in the When-New-Form-Instance trigger.

IF :PARAMETER.AKA_SLUZBA := '1' THEN
.....
END IF;

"Creating and Passing Parameter Lists" on-line help topic:
Parameters are passed to called forms by means of a parameter list. A parameter list is a named programmatic construct that is simply a list of parameter names (called keys) and their values.  
You can pass parameter values to forms invoked by the built-in subprograms CALL_FORM, OPEN_FORM, and NEW_FORM.  In addition, you can pass parameter values to other Oracle tools with the RUN_PRODUCT procedure.
A parameter you include in a parameter list can be either a text parameter or a data parameter.  The parameter type determines how its value is interpreted.

Text Parameters
The value of a text parameter being passed to a called product is a CHAR string that can represent the following:

     a user-defined form parameter defined in a form invoked by the CALL_FORM, OPEN_FORM, or NEW_FORM built-in subprograms

     a command line or user-defined parameter for a product invoked with the RUN_PRODUCT built-in subprogram

Data Parameters
The value of a data parameter being passed to a called product is always the name of a record group defined in the current form.  (A record group is a data structure that stores records derived from a query or through programmatic assignment.) Data parameters are used to pass data to products invoked with the RUN_PRODUCT built-in subprogram.  You cannot pass data parameters to forms.

The following table shows the structure of a parameter list that contains four parameters:

Key             Paramtype     Value
CITY             Text_Parameter     'BOGOTA'
CATEGORY     Text_Parameter     'EXPORTS'
MULTIPLIER     Text_Parameter     '.0275'
NEW_DATA     Data_Parameter     'RECORD_GROUP8'

Henka
0
 
LVL 22

Accepted Solution

by:
Helena Marková earned 400 total points
ID: 8216768
I think that this is an interesting article:

Global Variables and Package Variables

The purpose of this note is to explain Global Variables(Globals) and Package Variables, how global variable is different than a package variable, when to use globals instead of package variables.

Datatype:    Globals are always CHAR data. Package variables can be any PL/SQL data type.

Creation:    Globals are created the first time they are assigned.
Package variables are explicitly declared as part of a package.

Default Values:
Globals must have a value programmatically assigned.
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.
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.
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.
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. 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.
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.Package variables are declared explicitly in a package and can be explicitly initialized. They can be easily documented in the PL/SQL code. If you specifically need to create variables dynamically use globals else use package variables.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question