checkQuery()

Checks the syntax of a query.

Synopsis

int checkQuery(string aQuery);

Parameters

Parameter Meaning
aQuery Query to be checked

Return Value

Describes the syntactical correctness: 0 if syntax is ok, -1 in the event of an error.

Errors

Errors can be retrieved with getLastError(). The return value is then the appropriate error code.

Description

Checks the syntax of aQuery. The return value is 0 if the script is syntactically correct, otherwise the internal error code is retrieved (getLastError()). A detailed description of SQL can be found in the SQL help.

Example

The example checks if the syntax of the specified query is correct and then executes the query. The values of the query are written into a list and sort by value in descending order. The example also outputs the number of the values in the list.

  1. main()
    
    
    {
    
    
       int z;
    
    
       string start = "2017.09.01 11:25:00.000";
    
    
       string stop =  "2017.09.01 11:38:00.000";
    
    
       dyn_dyn_anytype tab;
    
    
       shape list1=getShape("SELECTION_LIST1");
    
    
       setValue(list1,"appendItem","Values of the data point ExampleDP_Arg1");
    
    
       DebugN("Check query - the query is OK if the return value is = 0, the return value is:", checkQuery("SELECT '_online.._value' FROM 'ExampleDP_Arg1' WHERE _DPT = \"ExampleDP_Float\"TIMERANGE(\""+start+"\",\""+stop+"\", 1, 0) SORT BY 1 DESC"));
    
    
       dpQuery("SELECT '_online.._value' FROM 'ExampleDP_Arg1' WHERE _DPT = \"ExampleDP_Float\"TIMERANGE(\""+start+"\",\""+stop+"\", 1, 0) SORT BY 1 DESC", tab);
    
    
       for(z=2;z<=dynlen(tab);z++)
    
    
       {
    
    
           DebugN(tab[z][2]);
    
    
           setValue(list1,"appendItem",tab[z][2]);
    
    
       }
    
    
       DebugN("Number of values:", list1.itemCount());

Assignment

Data point function

Availability

CTRL