Execute
This method sends the specified SQL command to the database via the database connection already opened by the function block FB_SQLDatabase.
Syntax
METHOD Execute : BOOL
VAR_INPUT
pSQLCmd: POINTER TO BYTE;
cbSQLCmd: UDINT;
END_VAR
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. |
Return value
Name | Type | Description |
---|---|---|
Execute | 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 := 'INSERT INTO myTable_Double ( Timestamp, Name, Value) VALUES ( $'2018-01-31 14:59:27$', $'Temperature$', 21.3)';
// call sql command
IF fbSQLCommand.Execute(ADR(sCmd), SIZEOF(sCmd)) THEN
IF fbSQLCommand.bError THEN
tcMessage := fbSQLCommand.ipTcResult;
nState := 255;
ELSE
nState := nState+1;
END_IF
END_IF