FB_SqlDbWrite

Overview

Type:

Function block

Available as of:

V1.0.0.0

Task

The FB_SqlDbWrite function block is used to perform SQL requests that update or modify the SQL database. The requests do not return any data.

Functional Description

The FB_SqlDbWrite function block is the user-interface for updating or modifying the SQL database.

After a rising edge on i_xExecute has been detected, a connection to the SQL Gateway is established using the parameters defined in the structure ST_ConnectionSettings. As soon as the connection has been established, the function block is capable to send one SQL request (given to input i_refRequestWstring) to the SQL database.

Status messages and diagnostic information are provided using the outputs q_xError (TRUE if an error has been detected), q_etResult, and q_etResultMsg.

Interface

Input

Data type

Description

i_xExecute

BOOL

The function block performs an SQL request in order to update or modify the SQL database upon rising edge of this input.

For more information, also refer to Behavior of Function Blocks with the Input i_xExecute.

i_refRequestWstring

REFERENCE TO [RequestWstring]

Reference to the request data that contains one SQL update request.

The following SQL query types are supported:

  • INSERT INTO

  • UPDATE

  • DELETE FROM

  • CREATE TABLE

  • CREATE VIEW

  • CREATE INDEX

  • ALTER TABLE

  • DROP TABLE

  • TRUNCATE TABLE

Any SQL request must be divided into individual strings that do not exceed a length of 200 characters each.

Adapt the size of the global parameters Gc_uiMaxRequest and Gc_uiRequestWstringLength according to the length of the SQL requests that you use in your application.

NOTE: To concatenate WSTRINGS, use the CONCAT function of Standard64 library.

i_uiNumOfWstrings

UINT

The number of needed WSTRINGS that contain the split SQL request.

The maximum number is limited by the global parameter Gc_uiMaxRequest.

In_Out

Data type

Description

iq_stConnSettings

ST_ConnectionSettings

Contains the information for connecting to an SQL Gateway and information on the SQL database.

Output

Data type

Description

q_xBusy

BOOL

If this output is set to TRUE, the function block execution is in progress.

q_xDone

BOOL

If this output is set to TRUE, the execution has been completed successfully.

q_xError

BOOL

If this output is set to TRUE, an error has been detected. For details, refer to q_etResult and q_etResultMsg.

q_etResult

ET_Result

Provides diagnostic and status information.

q_sResultMsg

STRING[255]

Provides additional diagnostic and status information.

For more information, also refer to Common Inputs and Outputs.