2 Replies Latest reply: Jan 6, 2013 5:10 PM by jsha RSS

    SQL Plus Error Logging

    jsha
      Hi,

      I am having trouble logging the sql errors from sqlplus. I am executing a sql script from a bat file using sqlplus with following command: sqlplus dbusrid/dbpass @export_data.sql >> log.log
      The script is outputting the results of a select to a csv file using spool as follows:

      set echo off
      set feedback off
      set pagesize 0
      set termout off
      set heading off
      set trimspool on

      spool c:\temp\output.csv

      select col1 || ',' || col2 || ',' || col3 from
      table;

      spool off

      If a sql error occurs then the output.csv is populated with the error. Is it possible to populate an error log with sql errors instead of or in addition to the output.csv?
      Ideally I would like all error output to be logged in the log.log file which is being populated from the bat file cmd mentioned above.
      I am new to oracle and sqlplus so Im sorry if this is a trivial question but I cannot seem to find the correct method.

      Thanks,

      J

      Edited by: user1099073 on Jan 3, 2013 10:53 PM
        • 1. Re: SQL Plus Error Logging
          WGabriel
          Hello,
          Is it possible to populate an error log with sql errors instead of or in addition to the output.csv?
          No, it is not possible to separate all errors into an error log. You can create only one output file via the spool command.
          This file will also contain all sql errrors.

          But: you can log all errors to a logging table (a default table or user defined) using a new sqlplus feature.

          see: http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch12040.htm#i2698945


          Kind regards,

          WoG
          • 2. Re: SQL Plus Error Logging
            jsha
            Hi WoG,

            The error logging table will suffice for my needs as I can react retrospectively to errors without relying on the spool file contents.

            Thanks very much,

            J