Reading from an write-only(OUT) parameter in pl/sql
Posted
by sqlgrasshopper5
on Stack Overflow
See other posts from Stack Overflow
or by sqlgrasshopper5
Published on 2010-05-18T11:50:17Z
Indexed on
2010/05/18
12:00 UTC
Read the original article
Hit count: 223
When I tried writing to an read-only parameter(IN) of a function, Oracle complains with an error. But that is not the case when reading from an write-only(OUT) parameter of a function. Oracle silently allows this without any error. What is the reason for this behaviour?. The following code executes without any assignment happening to "so" variable:
create or replace function foo(a OUT number) return number
is
so number;
begin
so := a; --no assignment happens here
a := 42;
dbms_output.put_line('HiYA there');
dbms_output.put_line('VAlue:' || so);
return 5;
end;
/
declare
somevar number;
a number := 6;
begin
dbms_output.put_line('Before a:'|| a);
somevar := foo(a);
dbms_output.put_line('After a:' || a);
end;
/
Here's the output I got:
Before a:6
HiYA there
VAlue:
After a:42
© Stack Overflow or respective owner