Domanda

I'm looking for a way to write resultset of a query to a file maybe analog of queryout of MS SQL or the COPY from PostgreSQL

When using something like

select count(*) from "table" OUTPUT TO 'results.txt' FORMAT TEXT

I'm getting

Could not execute statement. Syntax error near 'TO' on line 1 SQLCODE=-131, ODBC 3 State="42000" Line 1, column 1

When running it, as discribed in documentation like this:

select count(*) from "table";
OUTPUT TO 'results.txt' FORMAT TEXT

e.g. inside a procedure, I'm getting an error telling me that there is no result for being outputted.

È stato utile?

Soluzione 2

I found a solution for at least my problem. It's possible to put results into a temporary table and unload the temp table. So something like:

SELECT * INTO #tmpresultset FROM myTable
UNLOAD TABLE #tmpresultset to '/some/file'

Altri suggerimenti

You can specify the OUTPUT to a file in your SQL directly:

dbisql -c "connection-string" SELECT * FROM table; OUTPUT TO 'results.txt' FORMAT TEXT

As per the Sybase documentation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a dba.stackexchange
scroll top