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

Query.Value

The Query.Value function allows the script to access a particular value in the result set of the SQL query. The script can access the values in any row and any column (the columns correspond to the categories listed after SELECT in the query).

Syntax

Query.Value (<Row Number>, <Column Number>)

Description

Returns the value from the specified row and column in the SQL query result set.

Arguments

<Row Number> {integer}

The Row Number is the number of the row in the list that contains the value to be returned. 0 is the first row, 1 is the second row, 2 is the third row and so on. Do not enter the angle brackets <>.

<Column Number> {integer}

The Column Number is the number of the column in the list that contains the value to be returned. 0 is the first column, 1 is the second column, 2 is the third column and so on. The first column is the first category that is listed after SELECT in the SQL Query, for example, if the SQL Query contains SELECT Name, TypeDesc, then Name is the first column and is numbered 0. TypeDesc is the second column and is numbered 1.

Do not enter the angle brackets < >.

Returns

Variable. The value in the defined row and column.

Example:

A script returns the following result set which is displayed in a Queries List box:

To access the third value in the Type column, the script has to contain the following:

Query.Value (2,1)

As 2 is the third row (the row numbers begin at 0) and 1 is the second column. This is because the column numbers also begin at 0, and 0 is the column on the left-hand side of the list box.

This would return the third value in the Type column which is 'Trend'.


ClearSCADA 2015 R2