SQLCommandFromTagDB Function

Help Contents


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.

To run an SQL Command from a Program Tag, running on the SCADA Server, use the SQLCommandFromTagDB Function Block.


Informal Syntax:

SQLCommandFromTagDB( CommandText )

Formal Syntax:

        CommandText:=Expression )


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.


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.


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

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.


For the meaning of terms used in Fernhill SCADA.