Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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.

asked 30 Dec '10, 18:29

zippidydo's gravatar image

zippidydo
377151521
accept rate: 0%

edited 07 Oct '11, 16:33

Volker%20Barth's gravatar image

Volker Barth
40.2k361550822


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:

># filename

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.

Example

The >& redirection symbol redirects all output including error messages and statistics for the command on which it appears. For example:

SELECT *

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.

permanent link

answered 03 Jan '11, 12:34

John%20Smirnios's gravatar image

John Smirnios
12.0k396166
accept rate: 37%

Comment Text Removed

Wow, thanks for the pointer to "Output redirection" - and it's not only documented in V5.5 (whose topic I have obviously overseen although I have used that version quite a lot) but in all newer versions including V12, too: cf. http://dcx.sybase.com/index.html#1200en/dbusage/loexout.html.

(03 Jan '11, 13:41) Volker Barth

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.

-john.

permanent link

answered 31 Dec '10, 01:37

John%20Smirnios's gravatar image

John Smirnios
12.0k396166
accept rate: 37%

@John: Is that a documented feature? - I've never been aware of that:)

(02 Jan '11, 14:46) Volker Barth

The features of dbisqlc are no longer documented as dbisqlc has been replaced by the Java version. I'll post the relevant section from the dbisqlc documentation as another answer since comments here are limited in size.

(03 Jan '11, 12:31) John Smirnios

John, much appreciated. Great information to be used in many circumstances. Thanks!

(03 Jan '11, 17:24) zippidydo
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×105
×40
×20

question asked: 30 Dec '10, 18:29

question was seen: 5,984 times

last updated: 07 Oct '11, 16:33