Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie having woes with dbms_output in functions
On Feb 26, 9:22 pm, sean nakasone <seannakas..._at_yahoo.com> wrote:
> Hello,
>
> I have the following function:
>
> create or replace function seanFunc1(val varchar2)
> return varchar2 is
> begin
> dbms_output.enable(1000000);
> dbms_output.put_line('hello');
> return 'at the end';
> end;
> /
>
> When I call this function from the sqlplus command line, it does not print
> 'hello'.
> i.e.
> select seanFunc1('the') from dual;
>
> But when I call the function in a code block as shown below, it then
> prints.
>
> declare
> var varchar2(50);
> begin
> select seanFunc1('the') into var from dual;
> end;
> /
>
> Why is this? What's the simplest way to get output from a function?
A new feature around SQL*Plus 10g (though I can't seem to find it in the docs) is that it now executes its GET_LINES call after SQL statements instead of just after PL/SQL blocks, if serveroutput is set. In earlier versions of SQL*Plus you would enter a dummy PL/SQL block to get the output, e.g.
exec null Received on Wed Feb 28 2007 - 03:43:40 CST