Exporting Script results

Exporting a Script's result: DUMP LIB and DUMP @

DUMP LIB runs a library Script and writes its tabular result to a file. DUMP @ is the same command written the way a Script is run at the prompt. Named arguments come right after the Script, before TO and AS:

DUMP LIB customer-report.sql country='FR' TO customers_fr AS XLSX;
DUMP @customer-report.sql country='FR' TO customers_fr AS CSV;
  • The Script runs through the normal Script engine, with its arguments, variables, ON ERROR and OUTPUT. Its result tables are captured for the file instead of being displayed; ECHO messages still appear.
  • The exported data is the Script's own final tabular result. A scalar LET ... = SELECT query is never the export result, and a result shown earlier at the prompt is never used: a Script that produces no tabular result exports nothing (produced no exportable tabular result; nothing was exported).
  • The file is written only when the Script's status is SUCCESS. For any other status, nothing is written and an error says why: DUMP LIB errs.bsql not exported: the script finished with status COMPLETED_WITH_ERRORS.
  • With AS XLSX or AS ODS, TO names the file and, after a dot, the worksheet: TO customers_fr writes customers_fr.xlsx, worksheet DATA. Do not add the extension yourself.

File names, formats and every other option are described in Export.