LucidDbSysRoot EXPORT QUERY TO FILE
From LucidDB Wiki
Contents |
Syntax
CALL SYS_ROOT.EXPORT_QUERY_TO_FILE( query_sql, path_without_extension, with_bcp, delete_failed_file) CALL SYS_ROOT.EXPORT_QUERY_TO_FILE( query_sql, path_without_extension, with_bcp, with_data, delete_failed_file, field_delimiter, file_extension, date_format, time_format, timestamp_format)
Purpose
Exports the results from a SQL query to flat files.
Inputs
- query_sql: [VARCHAR(65535)] the sql for the query whose results should be exported. This needs to be single quoted, and single quotes within the sql itself needs to be escaped with another single quote.
- path_without_extension: [VARCHAR(65535)] the full path plus the file name for where you want the file exported. Doesn't include the extension for the file.
- directory: [VARCHAR(65535)] the directory where exported flat files are placed
- with_bcp: [BOOLEAN] indicates whether BCP files should be created. If true, BCP files will be created. If false, they will not be created
- with_data: [BOOLEAN] indicates whether data files should be created. If true, data files will be created. If false, they will not be created
- delete_failed_file: [BOOLEAN] indicates whether incomplete csv files for tables which failed export should be deleted. If true, failed files will be deleted, if false they will not
- field_delimiter: [VARCHAR(2)] the character used as a delimiter for the table column fields within each of the flat files created. Common delimiters could be commas ',' or tabs '\t' Field delimiters are limited to 2 characters
- file_extension: [VARCHAR(5)] the file extension to use for each of the flat files created. Common file extensions could be '.txt' or '.csv' File extension is limited to 5 characters. (ex. '.xxxx')
- date_format: [VARCHAR(50)] string parameter for formating date
- time_format: [VARCHAR(50)] string parameter for formating time
- timestamp_format: [VARCHAR(50)] string parameter for formating timestamp
Output
- flat file with the query results, and optionally bcp files, placed under the directory and file name specified.
Example
TODO