Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Prashant .

Asked: November 03, 2000 - 12:02 am UTC

Last updated: July 30, 2003 - 11:56 am UTC

Version: Forms 6

Viewed 10K+ times! This question is

You Asked

Dear sir,

I am working on forms 6. My Problem is I have created a login form and the login is done from table. I want to track the username of form throughout my multiform application so that whenever the user enters any data his username should be tracked.

In other words the first form I have developed is login form in which the user enters a user name and password. the password is verified from the table in the database and then after authentication he is allowed to enter the data entry forms from where he can enter data. Now what I want to do is keep his username in some variable like global.variable so that whenever he enters data from other forms his username should be retrievable.

I think it is possible by using global variable or by passing parameter to all the forms( which is less useful). Please tell me how to keep alive any such variable throughout the session of the user so that his username can be retrieved any time in the session of the user.

NB> the username I am taking about is not database loginname and password. I want to maintain separate userid which is retrieved from the table I have created.

and Tom said...

Well, you can use global variables:

A global variable is a Form Builder variable whose value is accessible to triggers and subprograms in any module that is active during the current session. A global variable stores a character string of up to 255 characters in length.
Global variables are not formally declared the way PL/SQL local variables are. Rather, you initialize a global variable the first time you assign a value to it:

:GLOBAL.my_var := TO_CHAR(:order.total * .85);

To reference a global variable, prefix the variable name with the word GLOBAL and a colon. The following example shows a global variable passed as an actual parameter to a procedure call:

calculate_discount(TO_NUMBER(:GLOBAL.my_var));

Referencing a global variable that has not been initialized through assignment causes a runtime error.
To destroy a global variable and release its memory, use the ERASE built-in procedure:

Erase('GLOBAL.my_var');


Or, you can pass it as a parameter to other forms.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Where to define Global Variable

Vijay Ahire, July 30, 2003 - 11:56 am UTC

Hi A'm new to form do you where to define Globle Variable & how to define.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library