using a package variable for a function argument (urgent) [message #329185] |
Tue, 24 June 2008 08:02  |
orafacjublu
Messages: 95 Registered: May 2006 Location: KOLKATA
|
Member |
|
|
Can any one give me an example how can I call a function which will except a package variable as an actual parameter.
say
create package p1
is
x number;
end;
create function f1(y number)
is
begin
return y;
end;
now -- execute p1.x:=10;
select f1(p1.x) from dual;
here it is showing error 'x' is not a procedure or undefined.
Then how to use the package variable as an argument for the function.
|
|
|
|
|
Re: using a package variable for a function argument (urgent) [message #329192 is a reply to message #329188] |
Tue, 24 June 2008 08:14   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
This is one of those places where SQL and PL/SQL behave differently.
SQL can only see procedures and functions - it can't see package variables, for reasons that I don't understand.
If you do:BEGIN
dbms_output.put_line(f1(pi.x));
END;
/ then it will work as you expect.
If you embed your SQL in some PL/SQL, then it will still work - because Pl/Sql gets the package value before the SQL is passed to the parser.:declare
v_ret varchar2(10);
begin
select p1.x
into v_ret
from dual;
dbms_output.put_line(v_ret);
end;
/
It's only if you try to access the package variable directly from SQL that it fails.
|
|
|
|
|
|