CreateCmd

This method is used to initialize an instance of the function block FB_SQLCommand with the already open database connection of the function block FB_SQLDatabase. The function block FB_SQLCommand only uses the database connection it was assigned via the CreateCmd method. Several instances of the function block FB_SQLCommand can be initialized with the same database connection.

The initialization of the function block FB_SQLCommand is completed in the same cycle. This means that neither the Busy flag of the function block nor the method return value of the CreateCmd method have to be checked.

Syntax

METHOD CreateCmd : BOOL
VAR_INPUT
    pSQLCommand: POINTER TO FB_SQLCommandEvt;
END_VAR

CreateCmd 1: Inputs

Name

Type

Description

pSQLCommand

POINTER TO FB_SQLCommand

Returns a new instance of the function block FB_SQLCommandEvt.

CreateCmd 2: Return value

Name

Type

Description

CreateCmd

BOOL

Displays the status of the method. Returns TRUE as soon as the method execution is finished, even in the event of an error.

Sample

VAR
    fbSqlDatabase : FB_SQLDatabaseEvt(sNetID := '', tTimeout := T#5S);
END_VAR
// create a command reference
IF fbSqlDatabase.CreateCmd(ADR(fbSqlCommand)) THEN
    IF fbSqlDatabase.bError THEN
        nState := 255; 
    ELSE
        nState := nState+1; 
    END_IF
END_IF

FB_SQLCommandEvt can then be used for the execution.