Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie having woes with dbms_output in functions

Re: newbie having woes with dbms_output in functions

From: Anurag Varma <avoracle_at_gmail.com>
Date: 26 Feb 2007 16:23:06 -0800
Message-ID: <1172535786.604478.14520@h3g2000cwc.googlegroups.com>


On Feb 26, 4: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?

In sqlplus you should issue

set serveroutput on size <nnnnnnn>

(e.g. set serveroutput on size 100000)
before calling a procedure which uses dbms_output. That will enable sqlplus to retrieve the output. dbms_output.enable will just enable the output to be placed into a buffer. serveroutput on will allow sqlplus to issue dbms_output.get_lines after each pl/sql call to print the output

Anurag Received on Mon Feb 26 2007 - 18:23:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US