User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL USER MANUAL VERSIONS

Ignition 8.1
Ignition 7.9
Ignition 7.8

Deprecated Pages

Employees

Sign In

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Scripting_function



Panel
titleDescription

Runs a named query and returns the results. Note that the number of parameters in the function is determined by scope. Both versions of the function are listed below.


Panel
titleClient Permission Restrictions

This scripting function has no Client Permission restrictions.


Panel
titleProject Scope Syntax

system.db.runNamedQuery(path, parameters, [tx], [getKey])

  • Parameters

String path - The path to the named query to run. Note that this is the full path to the query, including any folders.

PyDictionary parameters - A Python dictionary of parameters for the named query to use.

New_in
Version8.0.3



The following parameters were introduced in 8.0.3

String tx - An optional transaction ID, obtained from beginNamedQueryTransaction. If blank, will not be part of a transaction. 

Boolean  getKey - Optional. Only used for Update Query types. A flag indicating whether or not the result should be the number of rows affected (getKey=0) or the newly generated key value that was created as a result of the update (getKey=1). Not all databases support automatic retrieval of generated keys.

  • Returns

Object The results of the query. The exact object returned depends on the Query Type property of the Named Query: typically either a dataset when set to Query, an integer representing the number of rows affected when set to Update Query, or an object matching the datatype of the value returned by a Scalar Query.

  • Scope

Vision Client, Perspective Session


Panel
titleGateway Scope Syntax

system.db.runNamedQuery(project, path, parameters, [tx], [getKey])

  • Parameters

String  project The project name the query exists in.

String  path The path to the named query to run. Note that this is the full path to the query, including any folders.

PyDictionary parameters - A Python dictionary of parameters for the named query to use.


New_in
Version8.0.3


The following parameters were introduced in 8.0.3

String tx - An optional transaction ID, obtained from beginNamedQueryTransaction. If blank, will not be part of a transaction. 

Boolean  getKey - Optional. Only used for Update Query types. A flag indicating whether or not the result should be the number of rows affected (getKey=0) or the newly generated key value that was created as a result of the update (getKey=1). Not all databases support automatic retrieval of generated keys.

  • Returns

Object The results of the query. The exact object returned depends on the Query Type property of the Named Query: typically either a dataset when set to Query, an integer representing the number of rows affected when set to Update Query, or an object matching the datatype of the value returned by a Scalar Query.

  • Scope

Gateway



Panel
titleCode Examples


Code Block
languagepy
titleSimple Example - Without Parameters
# This example will run a Named Query without any parameters in the Project scope.
# The second argument in the function is NOT optional, so named queries that do not require a parameter must still pass an empty dictionary as an argument.

# Request the Named Query with an empty dictionary as the second parameter. 
system.db.runNamedQuery("folderName/myNamedQuery", {})



Panel


Code Block
languagepy
titleGateway Scope Example
# This example will run a Named Query without any parameters in the Gateway scope.
# The last argument in the function is NOT optional, so named queries that do not require a parameter must still pass an empty dictionary as an argument.

# Request the Named Query to execute. 
system.db.runNamedQuery("ProjectName", "folderName/myNamedQuery", {})



Panel


Code Block
languagepy
titleSimple Example - With Parameters
# This example will run a Named Query while passing some parameters in the Project scope.
# The Named Query is assumed to have two parameters already defined on the Named Query:
# param1 : A string
# param2 : An integer

# Create a python dictionary of parameters to pass
params = {"param1":"my string", "param2":10}
 
# Run the Named Query
system.db.runNamedQuery("myUpdateQuery", params)



Panel
titleKeywords

system db runNamedQuery, db.runNamedQuery