DBMS_OUTPUT.PUT_LINE not working in Stored Functions
513417Oct 10 2008 — edited Oct 11 2008Hi All,
I have one doubt, why is dbms_output.put_line not supported in Stored Functions?
create or replace function func_in_sql(var number) return varchar2
is
begin
If var is not null then
return to_char(dbms_output.put_line(var));
else
return to_char(dbms_output.put_line('null'));
end if;
end;
Returns error -
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/3 PL/SQL: Statement ignored
5/18 PLS-00222: no function with name 'PUT_LINE' exists in this scope
7/3 PL/SQL: Statement ignored
7/18 PLS-00222: no function with name 'PUT_LINE' exists in this scope
Any idea why this is happening?
I know that to print value one can just use return statement and value will be printed in SQL Prompt.
But what makes me think is why error for PUT_LINE method?
If error is not thrown at DBMS_OTUPUT then doesnt that mean all methods of DBMS_OUTPUT should be accessible in a function.
Thanks in advance!
Av.