You are here: Core Reference > Coding > Scripting > Query.Query

Query.Query

The Query Control Object that is returned by the AddQuery function has a Query property. The Query property represents the SQL Query that is used to retrieve data from the database.

Syntax

ControlObject.Query = "SQL Query"

Where ControlObject is the name of the variable (declared in your script) that is used to store the Query Control Object that is returned by the AddQuery function.

Description

Defines the SQL Query code that is used to retrieve data from the database.

Arguments

<SQL Query> {string}

<SQL Query> represents the SQL code that is used to retrieve data from the database. The SQL code has to be entered as a string (enclosed in double quotes) and has to use the correct SQL syntax. You need a good understanding of SQL to use this function effectively.

Do not enter the angle brackets < >.

Returns

None.

Example:

Query1.Query ="SELECT Name, TypeDesc FROM CDBObject"

Where:

  • Query1 is the name of the variable that stores the Query Control Object returned by the AddQuery function
  • "SELECT Name, TypeDesc FROM CDBObject" is the SQL Query that is used to retrieve data from the database. In this case, it retrieves the names of the items in the CDBObject class

ClearSCADA 2015 R2