Page 1 of 1

Action.ExportQuery

Posted: Fri Jan 21, 2022 4:54 pm
by yeti
Hello,

I would like to automatically export joined data into a CSV.

I have created a Query which works and can be exported manually into a CSV fine.

I am attempting to use the Action.ExportQuery function to export the data into a CSV automatically.

The query is named Joineddata

Code: Select all

Action.ExportQuery
   ·  "Joineddata"
   ·  "C:\\query.csv"
   ·  true
However I am getting the following error:

Code: Select all

01/21/2022 16:47:51	
	1 | Execution failed with unexpected error: 
	1 |   SQL logic error
	1 |   no such table: Joineddata
Please could you give me a hint as to where I am going wrong?

Thank you.

Re: Action.ExportQuery

Posted: Sat Jan 22, 2022 4:48 pm
by webmaster
This function needs an actual query, not a query name as the first argument, so something like this would work:

Code: Select all

Action.ExportQuery
   ·  "select * from MyTable"
   ·  "hello.csv"
   ·  true
If the query is large or has multiple lines, you can also use a script at Project Explorer > Scripting > Scripts since scripts can hold any arbitrary text. Just create a new script called MyQuery, then delete the default code, copy/paste your query and press the little save button. Then instead of the above code you can use this:

Code: Select all

Action.ExportQuery
   ·  Script.MyQuery
   ·  "hello.csv"
   ·  true

Re: Action.ExportQuery

Posted: Mon Jan 24, 2022 12:46 pm
by yeti
The script functionality worked perfectly, thank you! :mrgreen: