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

Home -> Community -> Usenet -> c.d.o.server -> Re: Output a variable to screen/file

Re: Output a variable to screen/file

From: <abalbekov_at_usa.net>
Date: Thu, 10 Dec 1998 15:19:54 GMT
Message-ID: <74ooqn$ehq$1@nnrp1.dejanews.com>


You can use dbms_output package if you invoke the procedure from within SQL*Plus. Just don't forget set serveroutput on:

SQL> set serveroutput on
SQL> spool spool_file
SQL> DECLARE
  2      l_var1        VARCHAR2(2000);

  3
  4 BEGIN
  5
  6       l_var1 := 'This line must be in my file';
  7       dbms_output.put_line( l_var1);
  8 END;
  9 /
This line must be in my file

PL/SQL procedure successfully completed. SQL>spool off

Working with dbms_output can be somewhat funny: you will not see output until after the procedure end, and its buffered output is limited to something. The limit can be set by the same set serveroutput command.

If you want have stored procedure write to file (instead of sql*plus on the client), you can use utl_file package. For more info see PL/SQL File I/O Chapter in Server Application Developer Guide.

Albert

In article <366D3E15.9D5C6ACE_at_ctp.com>,   Fabian Bakker <fbakke_at_ctp.com> wrote:
> Hello,
>
> Following is a pl / sql script example.
> I need to output the variable l_var1 to a file.
> How can I do that ? (spooling / print / show / print / refcursor??)
>
> Thanx
>
> DECLARE
> l_var1 VARCHAR2(2000);
>
> BEGIN
>
> l_var1 := 'This line must be in my file';
> print l_var1;
> END;
>
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Thu Dec 10 1998 - 09:19:54 CST

Original text of this message

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