Home » SQL & PL/SQL » SQL & PL/SQL » Value modification of global variable
icon5.gif  Value modification of global variable [message #236455] Thu, 10 May 2007 01:02 Go to next message
somen
Messages: 9
Registered: May 2007
Location: KOLKATA
Junior Member
Suppose there is global variable var_g number :=10; in a package header(say name of the package is pack1). There is a procedure proc1 defined in pack1, which modifies the value of var_g as 20 (by var_g :=20;). After this, what value will hold var_g? (10 or 20?)
Re: Value modification of global variable [message #236466 is a reply to message #236455] Thu, 10 May 2007 01:14 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Before or after calling the procedure that modifies the value?

Regards
Michel
Re: Value modification of global variable [message #236499 is a reply to message #236466] Thu, 10 May 2007 02:09 Go to previous messageGo to next message
somen
Messages: 9
Registered: May 2007
Location: KOLKATA
Junior Member
After calling pack1.proc1, what will the value of pack1.var_g?
Thank you very much for early reply.
Re: Value modification of global variable [message #236502 is a reply to message #236499] Thu, 10 May 2007 02:13 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
After calling, the value is the one set by the procedure (20).
Is this not the purpose of the procedure?

Regards
Michel
Re: Value modification of global variable [message #236514 is a reply to message #236502] Thu, 10 May 2007 02:40 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
This is very easy to test. Just create the package and the procedure.
You learn most by experimenting yourself; you will not forget things you found out yourself, but you will forget things you get by asking others.
Re: Value modification of global variable [message #236548 is a reply to message #236455] Thu, 10 May 2007 04:27 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Remember that when you are experimenting, test for the value of your variable in different sessions (i.e. log in as a different user to display the value of the variable before and after running the procedure that changes the variable's value in the original session.)
Re: Value modification of global variable [message #236556 is a reply to message #236548] Thu, 10 May 2007 04:40 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Can you explain what you meant?

Regards
Michel
Re: Value modification of global variable [message #236561 is a reply to message #236556] Thu, 10 May 2007 04:45 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
pablolee is right, his advise would show the OP that only in the session you ran the procedure, the package value changes.
Re: Value modification of global variable [message #236564 is a reply to message #236561] Thu, 10 May 2007 04:47 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Well, I think he meant the opposite, this is why I asked for more.

Regards
Michel
Re: Value modification of global variable [message #236681 is a reply to message #236564] Thu, 10 May 2007 11:08 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Michel,
I did not mean the opposite. I meant exactly what Frank said. Actually what I meant was for the OP to try it and see what the result would be rather than explain it so that he wouldn't have to try and do any of his own work. Smile
Re: Value modification of global variable [message #236917 is a reply to message #236548] Fri, 11 May 2007 05:46 Go to previous message
somen
Messages: 9
Registered: May 2007
Location: KOLKATA
Junior Member
Thanks all,
for your valuable suggestions.....
somen.
Previous Topic: 10G (Group by - Order By) doubt
Next Topic: Complex Calculations
Goto Forum:
  


Current Time: Mon Dec 05 21:29:43 CST 2016

Total time taken to generate the page: 0.11415 seconds