FB_SqlDbWrite

Overview

Type:

Function block

Available as of:

V1.0.0.0

G-SE-0053402.1.gif-high.gif

 

 

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.

As long as the function block is executed, the output q_xBusy is set to TRUE. After a command has been successfully completed, the output q_xDone is set to TRUE.

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.

i_refRequestWstring

REFERENCE TO [RequestWstring] 

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

The following SQL query types are supported:

oINSERT INTO

oUPDATE

oDELETE FROM

oCREATE TABLE

oCREATE VIEW

oCREATE INDEX

oALTER TABLE

oDROP TABLE

oTRUNCATE 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.