When you want to export the result of a query to a file using the OUTPUT statement, you apparently have the option to APPEND the result to an existing file. However when I try to run this command like in the example below it fails saying "Syntax error at line2":
SELECT myFIELD FROM myTABLE where myOtherField='XYZ'; OUTPUT TO 'myTextfile.txt' FORMAT ASCII APPEND
Without the APPEND it works fine so it does not seem to recognize the APPEND option. I tried with ASA 6 and 11 ... same result.
Is this an known issue?
I cannot reproduce your problem. I tested with the latest 11.0.1 build, connected to the demo database that comes with SQL Anywhere, opened DBISQL, and executed the following statements twice:
select * from departments; output to 'c:\test.txt' FORMAT ASCII APPEND
The "test.txt" file contains 10 lines, as expected. There was no syntax error.
"TEXT" was added as a synonym for "ASCII" in 11.0.1 starting in build 1150. They both mean the same thing.
Are there any other details you can provide to help us reproduce the problem?
answered 16 Nov '12, 17:28
Have you tried
OUTPUT TO 'myTextfile.txt' APPEND FORMAT TEXT
answered 16 Nov '12, 11:41
The docs of 11.0.1 say this about append:
ASCII doesn't seem to be an "official" output format for the output statement at least in 11:
Presumably ASCII should be a synonym for TEXT. Btw. i don't get an error with FORMAT ASCII APPEND in 188.8.131.5206. Perhaps this error was already corrected in a newer build?
answered 16 Nov '12, 11:47
Are you using dbisqlc (in contrast to DBISQL aka Interactive SQL)?
I'm using dbisqlc quite often and typically stumble over the fact that dbisqlc does not support all of the documented OUTPUT command's options, and APPEND is not supported AFAIK.
So, with SA 184.108.40.20669, the following query:
select * from departments; output to 'c:\test.txt' FORMAT TEXT APPEND
does work as expected with DBISQL but reports a syntax error with dbisqlc.
For further reading, confine this FAQ and John's (i.e. the expert's) answer: