Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Global Variable passed as IN parameters, bug or feature?
Hi Guys,
I have a strange thing happening related to global variables, and I
want to know whether this is a bug or a feature. I am using Oracle
10g.
I have this package.
create or replace package test
is
a number:=1; -- global variable
procedure pass_a;
end test;
/
create or replace package body test
is
procedure print_a (p_a in number)
is
begin
a:=2;
dbms_output.put_line(p_a);
end print_a;
procedure pass_a
is
begin
print_a(a);
end pass_a;
end test;
/
When I call test.pass_a from sqlplus, the procedure should call print_a(a). "a" at this time is equal to 1, so basically, I am passing 1 to the print_a. In print_a, I change the global variable 'a' to 2 before I issue the dbms_output. Note, I am changing the global variable and not the IN parameter p_a. p_a should still be equal to 1. To my surprise, the dbms_output prints 2 and not 1. This means, changing the global variable that was passed to the procedure actually changes the local variable itself. Is this correct? Is it a feature, or a bug? Thanks. Received on Tue Nov 29 2005 - 09:48:10 CST
![]() |
![]() |