# How to Use PxPlus Query Definitions in Non-NOMADS Environments

> Source: https://manual.pvxplus.com/how-to/how-to-use-qry-defs-in-non-nomads

Your application does not have to be running in a NOMADS environment to take advantage of some of the PxPlus NOMADS features. One of the multi-faceted features is the **[NOMADS Query Subsystem](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/overview)**.

A query definition basically defines a custom dataset that can draw data from multiple related files and specify fields and formulas to include. It can be used to:

|  |  |
| --- | --- |
| **[Display a Lookup Table](https://manual.pvxplus.com/how-to/display-lookup-table)** | Display a table lookup for displaying records from a defined dataset and return a selected value. |
| **[Read a Query Dataset](https://manual.pvxplus.com/how-to/read-a-qry-dataset)** | Read records from a custom dataset that can comprise multiple files and selected fields. |
| **[Load List Box and Grid Controls](https://manual.pvxplus.com/how-to/load-lbox-and-grid-ctrls)** | Automatically load List Box and Grid controls based on a query definition. |
| **[Create Charts](https://manual.pvxplus.com/how-to/create-charts)** | Generate charts in the query Lookup Table and create chart images. |
| **[Generate Spreadsheet Data](https://manual.pvxplus.com/how-to/generate-spreadsheet-data)** | Generate export files to be used in spreadsheets. |
| **[Print a Simple Report](https://manual.pvxplus.com/how-to/print-simple-rpt)** | Print a simple report based on the query definition. |
| **[Supply Data to the PxPlus Report Writer](https://manual.pvxplus.com/how-to/supply-data-to-rpt-writer)** | Serve as an input source for the PxPlus Report Writer to generate more complex reports. |
| **[Display Information in a Browser](https://manual.pvxplus.com/how-to/display-info-in-browser)** | Display information in various formats (lookup, chart, report) in a browser. |
| **[Display Data in Webster+](https://manual.pvxplus.com/how-to/display-data-in-webster)** | Used in conjunction with several Webster+ short codes to display data. |

Note:  
The above features are also available when using the NOMADS environment.

## How to Define a Query

These steps explain how to define a query.

|  |  |
| --- | --- |
| 1\. | Get ready to define a query. A query definition consists of selecting a main file, related files to link to, and fields and formulas to include.<br>The main file could be a native PxPlus file or an external database table. While it is possible to define a query for a native file with no embedded data dictionary, using field number references with offsets and field lengths, it is much easier to use files with data dictionary definitions. If your native file consists of delimited fields, you can use the **[Visual Dictionary Utility](https://manual.pvxplus.com/visual-dictionary/visual-dictionary-introduction)** to help define the data dictionary for the file or use **[Data Dictionary Maintenance](https://manual.pvxplus.com/data-dictionary/data-dictionary-maintenance/overview)** to define native files with more complex structures or add more detail.<br>As for external databases, you can use the **[Database Import Utility](https://manual.pvxplus.com/data-dictionary/data-dictionary-maintenance/database-import)** to create data dictionary entries for the tables in the database, as well as prefix file entries or link files that allow you to reference the tables using a simple table name. You should also define data dictionaries for any related files you want to access. |
| 2\. | Create and **[Open a Library File](https://manual.pvxplus.com/nomads-graphical-application/nomads-development/library-object-selection/opening-a-library-file)**.<br>To create a ***Query*** object, use the **[Library Object Selection](https://manual.pvxplus.com/nomads-graphical-application/nomads-development/library-object-selection/console-and-object-list)** window. This window is used for **[Creating Library Objects](https://manual.pvxplus.com/nomads-graphical-application/nomads-development/library-object-selection/creating-library-objects#query)**. Give the query object a name. The name you give to the library and query object will be used later to identify the query definition.<br>![](https://manual.pvxplus.com/migration-assets/6150ff1e286d078059634a37cbd16dd849b62e20d1cbf211d90ad4594adb6d31.png) |
| 3\. | **[Define the Query](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/defining-a-query)**. If your native file or table has a data dictionary, you can select it in the **[Query Header Definition](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/query-header)** using the logical file name from the data dictionary.<br>![](https://manual.pvxplus.com/migration-assets/caa30f440ba01377201f0e8e1b32d7491f4aaaaeebc59d492e404c0cd8c09f25.png) |
| 4\. | In the **[Query Definition](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/query-definition)**, invoke the **[Query File Link](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/query-file-link)** panel to add the links to related files.<br>![](https://manual.pvxplus.com/migration-assets/12a567d898c652f99de89e4f00ac5a1ec6e860d7b68dbf715ebe52b4790eeb8e.png) |
| 5\. | In the query definition, select the fields and define any **[Formulas](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/query-formula)** you want to include in your dataset.<br>Depending on your intended use for the query definition, you may want to alter some of the column settings and display options if the query is used for visual display.<br>![](https://manual.pvxplus.com/migration-assets/836b12db1dfde208e60fdc982af776a553ac5f570110706a7a036fe92ce94a24.png) |
| 6\. | Set up **[Query Selection Criteria](https://manual.pvxplus.com/nomads-graphical-application/dictionary-based-development/query-subsystem/query-selection-criteria)** to filter your data. |
| 7\. | When your query definition is complete, test it, make any adjustments and save it. After that, the query is ready to use. |
