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?

asked 16 Nov '12, 11:18

Berto's gravatar image

Berto
46114
accept rate: 0%

edited 19 Nov '12, 10:33

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819

Please show us the EXACT code that gives the error, not a "command like" the one that gave the error.

(17 Nov '12, 10:04) Breck Carter

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?

permanent link

answered 16 Nov '12, 17:28

Chris%20Irie's gravatar image

Chris Irie
8051314
accept rate: 46%

Have you tried

OUTPUT TO 'myTextfile.txt' APPEND FORMAT TEXT
permanent link

answered 16 Nov '12, 11:41

Martin's gravatar image

Martin
9.0k130169257
accept rate: 14%

The docs of 11.0.1 say this about append:

The APPEND keyword is valid if the output format is TEXT, FIXED, or SQL

ASCII doesn't seem to be an "official" output format for the output statement at least in 11:

output-format : TEXT | FIXED | HTML| SQL | XML

Presumably ASCII should be a synonym for TEXT. Btw. i don't get an error with FORMAT ASCII APPEND in 11.0.1.2606. Perhaps this error was already corrected in a newer build?

permanent link

answered 16 Nov '12, 11:47

Markus%20D%C3%BCtting's gravatar image

Markus Dütting
53641220
accept rate: 30%

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 12.0.1.3769, 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:

permanent link

answered 17 Nov '12, 18:00

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819
accept rate: 34%

edited 17 Nov '12, 18:03

To answer some questions:

The EXACT code i was running =
select FLD_VAL1 from param where FLD_NAME='COUNTRY_OFF_INSTALL';
OUTPUT TO 'country_of_install.txt' FORMAT ASCII APPEND
;

I also tried: ... OUTPUT TO 'myTextfile.txt' APPEND FORMAT TEXT but it returned same error

I noticed that for the test I did:
- against Sybase 6.0.3: I used dbisql.exe
- against Sybase 11.0.1: I used dbisqlc.exe
Reason: these sql editors are part of a software package we distribute. The older version of our software package is containing dbisql.exe while the newer one is having dbisqlc.exe installed (for maintenance purposes on the application db).

So, as i can derive from the link Volker posted (thx again!):
It seems for Sybase v11.0.1, dbisqlc.exe does not support the "OUTPUT APPEND". And I guess dbisql.exe (notice: without the c) in Sybase v6.0.3. probably does not either.

I need the functionality for v6.0.3. and was just curious how v11.0.1 was behaving. So seems I need to look for another solution.

Big thanks for your help!

Krgds Berto

(19 Nov '12, 09:01) Berto
Replies hidden

Can't tell on the 6.0.3 DBISQL tool (FWIW, with v7, I'm quite sure APPEND is supported). But without that, outputting to different files and concatenating them with COPY + may be an easy solution.

(19 Nov '12, 10:32) Volker Barth
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:

×143
×28
×20
×7
×1

question asked: 16 Nov '12, 11:18

question was seen: 6,823 times

last updated: 19 Nov '12, 10:33