Skip to end of metadata
Go to start of metadata


What Are Named Queries?

Named Queries are preconfigured queries that may be invoked elsewhere in a project. Named Queries are conceptually very similar to Project Scripts; defined in a single location, and then referenced in multiple places throughout the project. When executing a Named Query, parameters may be passed to return a dynamic result set. This way, a query may be written once, and then called from multiple locations throughout the project. 

The Named Queries Welcome tab allows you to create three types of named queries. Each one of the named query types is basically a template to help you get started creating your own query.  Once you select a Named Query type, enter a name, and press 'create', and the specific named query template will open.  The Select Query and the Update Query will have some sample parameters and queries to help you get started.  The Named Queries Welcome tab will show you any recently modified named queries along with the date it was modified and who modified it. You can even double click on a recently modified query and open it. 

The Named Queries Welcome tab provides a quick way to create a new query and update existing ones. 


On this page ...

IULocgo


Named Query Overview

Named Queries have their own workspace in the Project Browser section of the Designer.


Secure Query Execution

While clients may request data from a Named Query, the actual execution of the query always takes place on the Gateway. Clients simply specify which query should run, and pass parameters that the Gateway will use. Additionally, the Gateway has an opportunity to restrict access to the query based on Security Zone and/or User Role. This provides a single interface to restrict access to the queries, and better protect your data. Additionally, queries cannot be modified by a Client other than by passing variables into it. This creates a very secure method to control what queries are being run against your database.


Where Are Named Queries Used?

Named Queries may be used in multiple locations in Ignition. They are used in all the same places that a normal SQL query would be used. Here are a few examples of locations in which named queries can be used. A more detailed example of a named query is provided here

Binding

A Query Binding type has been added to leverage named queries for any component property bindings. Named Query Parameters may be bound to Tags or other properties on the same window, allowing your users to modify the resulting dataset by manipulating other components similar to the original SQL Query binding type. You can also select and update a query to simulate a bi-directional binding to the database.

Reporting

A Named Query Data Source has been added to Reports. Report Parameters may be used by the Named Query to generate dynamic reports.

Scripting

The system.db.runNamedQuery function may be used to called a Named Query from any Python script. This provides a secure method to execute a query from any location in Ignition.



  • No labels