ExecuteDataReturn

This method sends the specified SQL command to the database via the database connection already opened by the function block FB_SQLDatabase. An instance of the function block FB_SQLResult can be transferred for reading the returned records.

Syntax

METHOD ExecuteDataReturn : BOOL
VAR_INPUT
    pSQLCmd: POINTER TO BYTE;
    cbSQLCmd: UDINT;
    pSQLDBResult: POINTER TO FB_SQLResult;
END_VAR

ExecuteDataReturn 1: Inputs

Name

Type

Description

pSQLCmd

POINTER TO BYTE

Indicates the pointer address of a string variable with the SQL command to be executed.

cbSQLCmd

UDINT

Indicates the length of a SQL command to be executed.

pSQLDBResult

POINTER TO FB_SQLResult

Returns a new instance of the function block FB_SQLResult.

ExecuteDataReturn 2: Return value

Name

Type

Description

ExecuteDataReturn

POINTER TO BYTE

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

Sample

Uses the command created by FB_SQLDatabaseEvt.CreateCmd().

VAR
    fbSqlCommand : FB_SQLCommandEvt(sNetID := '', tTimeout := T#5S);
    tcMessage    : I_TcMessage;
END_VAR
// you can generate this with the SQL Query Editor 
sCmd := 'SELECT ID, Timestamp, Name, Value FROM myTable_Double';

// call sql command
IF fbSQLCommand.ExecuteDataReturn(ADR(sCmd), SIZEOF(sCmd), ADR(fbSqlResult)) THEN
    IF fbSQLCommand.bError THEN
        nState := 255; 
    ELSE
         tcMessage := fbSQLCommand.ipTcResult;
        nState := nState+1; 
    END_IF
END_IF

FB_SQLResultEvt can then be used to read the data.