SQLCommandFromTagDB Function

Help Contents

Introduction

The SQLCommandFromTagDB Function executes an SQL Command on the Fernhill SCADA database.

Functions and Function Blocks

The SQLCommandFromTagDB Function is intended for use in an Operator Action. Operator Actions run in response to user input gestures in the Operator Interface. In an Operator Action, code execution is suspended until the function completes.

If you want to run an SQL Command from a Program Tag, running on the SCADA Server, use the SQLCommandFromTagDB Function Block.

Syntax

Informal Syntax:

SQLCommandFromTagDB( CommandText )

Formal Syntax:

SQLCommandFromTagDB( 
        CommandText:=Expression )

Parameters

Parameter Type Description
CommandText ANY_STRING The SQL command to execute on the Fernhill SCADA Tag Database. See Fernhill SCADA Structured Query Language (SQL) for the syntax of this parameter.

Return Value

The function SQLCommandFromTagDB returns a DINT value that represents the SQL Command Object.

Remarks

The SQLCommandFromTagDB Function is only available to IEC 61131-3 code in Operator Actions.

To create a SQLCommand object in an IEC 61131-3 Program Tag, use the SQLCommandFromTagDB Function Block.

Examples

  1. Query and display the number of tags in the Fernhill SCADA Server.
    VAR
        TagCount, CommandID : DINT;
    END_VAR
    
        CommandID :=
            SQLCommandFromTagDB(
                "SELECT Count(*) FROM TagCore");
    
        IF SQLCommandFetchRow( CommandID ) THEN
    
            TagCount := TO_DINT(SQLCommandGetValue( CommandID, 0 ));
    
            MessageDialog(
                "Tag Count",
                CONCAT( "Total tags = ", TO_STRING(TagCount)));
    
        END_IF

Standards Compliance

The SQLCommandFromTagDB Function is an extension to the IEC 61131-3 standard.

Further Information

SQLCommand Data Object

To learn how to use the SQLCommand data object.

Data Objects

To learn how to use data objects in IEC 61131-3 code.

IEC 61131-3

To learn how IEC 61131-3 is used in Fernhill SCADA.

Glossary

For the meaning of terms used in Fernhill SCADA.