When running a sql script through command prompt/dbisqlc as below:
dbisqlc -c "dsn=[whatever]" c:\temp\runthiscript.sql
with SET TEMPORARY OPTION ON_ERROR = 'CONTINUE'; included in the script,
is there a way to log or capture the information from the messages pane? I would be running updates, deleted, or inserts and am interested in capturing any foreign key errors for follow up.
From the v5.5 dbisqlc documentation:
Output redirection can be used to export data as an alternative to the OUTPUT statement.
The output of any command can be redirected to a file or device by putting the ># redirection symbol anywhere on the command. The redirection symbol must be followed by a file name, as follows:
Output redirection is most useful on the SELECT statement. The SET OUTPUT_FORMAT command can be used to control the format of the output file.
The >& redirection symbol redirects all output including error messages and statistics for the command on which it appears. For example:
FROM employee >& filename
outputs the SELECT statement to the file, followed by the output from the SELECT statement and some statistics pertaining to the command.
The >& redirection is useful for getting a log of what happens during a READ command. The statistics and errors of each command are written following the command in the redirected output file.
If two > characters are used in a redirection symbol instead of one (>>#, >>&.), then the output is appended to the specified file instead of replacing the contents of the file. For output from the SELECT command, headings are output if and only if the output starts at the beginning of the specified file and the output format supports headings.
answered 03 Jan '11, 12:34
I don't think there is a way to log just the messages pane but you can log everything (include result sets from select statements) with the ">&" operator. If you are using it on a command line, you will need to quote it to so that it isn't interpreted as output redirection by the shell:
dbisqlc -c "..." read foo.sql ">&" output.txt
There is also a ">#" operator that only logs result sets (no messages) as well as ">>&" and ">>#" which append to the output file rather than create a new one.
answered 31 Dec '10, 01:37