3 Replies Latest reply: Jun 14, 2011 9:40 PM by 868935 RSS

    spool sql*plus's output

    694243
      Hello,

      I want to write all the output of sql*plus in a file, so I did this:
      SQL> SPOOL text.out
      SQL> host date;
      Tue Jan 26 15:46:17 UTC 2010
      
      SQL> SPOOL OFF
      SQL> exit
      And the output was:
      bash> cat text.out
      SQL> host date;
      
      SQL> SPOOL OFF
      So where is the date in the text.out???

      Thanks for any help!
        • 1. Re: spool sql*plus's output
          730428
          The HOST command writes a separate output that is printed on sqlplus screen but is ignored by the spool command.

          The only workaround I can suggest you is the following:
          SQL> host date > a.txt  -- Doing this outside the spool
          
          SQL> spool a.txt append  -- append mode not to loose the previous content of the file
          SQL> select 1 from dual;
          
                   1
          ----------
                   1
          
          SQL> spool off
          SQL> host cat a.txt
          Tue Jan 26 17:20:12 CET 2010
          SQL> select 1 from dual;
          
                   1                                                                      
          ----------                                                                      
                   1                                                                      
          
          SQL> spool off
          
          SQL> 
          Max
          [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/]
          • 2. Re: spool sql*plus's output
            749453
            before your comand check this sets


            set head off
            set pages 0
            set verify off
            set feedback off
            set lines 100
            SET SERVEROUTPUT on
            spool text.out
            set head off


            then fix your output

            Edited by: user11335994 on 16:01 27/01/2010
            • 3. Re: spool sql*plus's output
              868935
              Why not try:

              select to_char(sysdate,'yyyymmddhh24mi') from dual;

              or something similar - works everytime.