DBeaver Version: 23.2.4.202311051706
Database: Informix
O.S.: Windows 10
I have a script file that I want to export the results of multiple select statements. Below is an example of the script.
-- Script parameters/variables
@set my_number = 1800003835
-- export command
@export { "type": sql, "producer": { }, "consumer": { "outputFolder":"d:/temp/dbeaver/exports", "appendToFile":"true", "useSingleFile":"true" }, "processor": { "includeAutoGenerated": "true"} }
select
*
from
table1
where
mninum = '${my_number}';
select
*
from
table2
where
mninum = '${my_number}';
select
*
from
table3
where
mninum = '${my_number}';
It executes the first query and exports it. Then it stops. I am using the "Execute SQL Script" button. I tried adding the @export command before the other queries, only the first one is executed. Is there a way to get it to execute and export all the queries?
AFAICT from the DBeaver manual for the @export
command, you can (must) have a single SQL (SELECT) statement after the @export
command.
The body of the command consists of JSON text…
Due to certain limitations, it must be written on a single line, without line delimiters…
… The command itself doesn't do anything. It must be followed by any other query…
(Emphasis in original documentation!)
If I'm reading that correctly, you must use multiple @export
commands to export the data from multiple SELECT statements.
This doesn't explain why you cannot have multiple @export
commands in a single script file. I've not used DBeaver, so I'm not qualified to explain why that restriction seems to be in place.