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