Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Output a variable to screen/file
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);
6 l_var1 := 'This line must be in my file'; 7 dbms_output.put_line( l_var1);8 END;
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