# \*TOOLS/QRYEXPORT Create an Export File Based on Query Definition

> Source: https://manual.pvxplus.com/utilities/qryexport

## Invocation

**CALL "\*tools/qryexport"**, *queryName$, queryLib$, exportfile$* \[*, queryopts$, show_flg$*\]

***Where:***

|  |  |  |  |
| --- | --- | --- | --- |
| *queryName$* | Required | Input | Name of the query to use to generate the export file. |
| *queryLib$* | Required | Input | Library where the query is defined. |
| *exportfile$* | Required | Input | Name of the export file to write to. (To write to a client machine, include the **\[lcl\]** prefix in the file name.)<br>Export file types are determined by their file extension. Supported types include:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *.csv* \| Comma-separated \|<br>\| *.slk* \| Symbolic link \|<br>\| *.txt* \| Tab delimited \|<br>\| *.xml* \| Microsoft XML \| |
| *queryopts$* | Optional | Input | Flag to determine additional content to add to the file. Possible values are:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| **""** Null \| ***(Default)*** No additional content. \|<br>\| H \| Show hidden columns in the query definition. (By default, hidden columns are excluded from the file.) \| |
| *show_flg$* | Optional | Input | Flags to determine interactive behavior at run time. Possible values are:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| **""** Null \| ***(Default)*** The export file is generated silently. \|<br>\| D \| The generated file is displayed using the default app (e.g. Excel). \|<br>\| E \| Error message for errors that occur during file generation are displayed in message boxes. \|<br>\| P \| A progress bar is displayed while the file is generated. \|<br>\| **\*** \| All of the above. \|<br>Note:  <br>Any combination of D, E and P is acceptable. |

## Description

This utility is a CALLed program that exports data to a spreadsheet-supported file based on a query definition. The file has of a header record consisting of the column headings defined in the query, followed by data records of the resulting query data set. By default, columns defined as *hidden* in the query definition are excluded but can be included by setting the *queryopts$* optional parameter to "H".

The file types that are supported are comma separated (*.csv*), tab delimited (*.txt*), symbolic link (*.slk*) and Microsoft XML (*.xml*). The type of file is determined by its file extension. Unsupported file extensions will result in Error #17: Invalid file type or contents.

Note:  
This program will EXIT ERR if an error is encountered.

*(The QryExport utility was added in PxPlus 2024.)*
