Home » Developer & Programmer » Forms » Global Variable in developer 9i (Oracle developer 9i, Windows XP)
Global Variable in developer 9i [message #279877] Sun, 11 November 2007 06:35 Go to next message
janaq
Messages: 22
Registered: August 2007
Junior Member
Dear All,

I want to use global variable to retrive data in my forms. I have two forms namely Login and Inprogress. Please can any one help me with the syntax give below:

In the Login form I have the below mentioned code on When-Button-Press:

     
    Declare
       v_uname varchar(100);
       v_pwd varchar(100);
       v_usertype varchar(100);
       alert_id alert;
       choice number;
       alert_id1 alert;
       choice1 number;
       v_num number;
    
    begin
    	select  username, password, usertypeid into v_uname, v_pwd, v_usertype
    	from user_master
    	where username = :login.username
    	and user_master.active = 'Yes';
    		
    	select  count(*) into v_num
    	from user_master
    	where username = :login.username
    	and password = :login.password
    	and user_master.active = 'Yes';
    		
    	if v_num > 0 then
    		if v_usertype = 1 then
    			call_form ('E:\FinalProject\FinalProject\CUSTOMER.fmx', hide, do_replace);
    			:global.user_id :=1;
    			end if;
    


In the Inprogress form where I want to call the global variable I have the below code on When-New-Form-Instance

     
    set_block_property('INPROGESS',default_where,'USERID='||:global.user_id);
    execute_query;
    


When I login with the Login form it logs in successfully but when i call the inprogress form it gives me the error:

    FRM:40815: Variable GLOBAL.USERID does not exit


Can any one help me with this please.

Regards.
Re: Global Variable in developer 9i [message #279893 is a reply to message #279877] Sun, 11 November 2007 08:51 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One reason might be that 'v_num = 0' (i.e. there's no record in the 'user_master' table that satisfies the WHERE condition).

Another one is that 'v_usertype <> 1'.

The third reason is wrong placement of the global variable initialization; move it in front of calling the form, like in the following example:
if v_usertype = 1 then
   :global.user_id :=1;
   call_form ('E:\FinalProject\FinalProject\CUSTOMER.fmx', hide, do_replace);
end if;

Does any of these suggestion help?
Re: Global Variable in developer 9i [message #279970 is a reply to message #279893] Mon, 12 November 2007 02:09 Go to previous messageGo to next message
janaq
Messages: 22
Registered: August 2007
Junior Member
Thanks alot for your help, the third reason worked i.e. the wrong placement of Global Variable.
Re: Global Variable in developer 9i [message #280069 is a reply to message #279877] Mon, 12 November 2007 07:12 Go to previous messageGo to next message
janaq
Messages: 22
Registered: August 2007
Junior Member
Hi,

Another help required, can you please tell me how can I assign the value of global variable to a database column. Can you check the code below:


    update response
    	set userid = :global.user_id
    	where responseid = :response1.responseid;
    



Is this the correct way?

Regards.
Re: Global Variable in developer 9i [message #280076 is a reply to message #280069] Mon, 12 November 2007 07:23 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, it is (as far as I can tell). However, note that global variables are of a CHARACTER datatype (so take care about possible datatype conversion (for example, character to date).
Re: Global Variable in developer 9i [message #280091 is a reply to message #280076] Mon, 12 November 2007 08:00 Go to previous messageGo to next message
janaq
Messages: 22
Registered: August 2007
Junior Member
Hi,

Sorry I mistakenly asked about the data update, actually I want to know that while inserting the data into the database from a form how can I assign the value of Global Variable to a column of that table i.e. on inseting the response i want to assign the userid which i have pass from the global variable.

Please help!!!

Regards.
Re: Global Variable in developer 9i [message #280191 is a reply to message #280091] Mon, 12 November 2007 14:09 Go to previous message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You might try with the PRE-INSERT trigger, something like
:block.id := :global.id;
Previous Topic: how can i pass block name to procedure
Next Topic: Compile the forms
Goto Forum:
  


Current Time: Sun Feb 09 20:50:10 CST 2025