Description | With this action you can execute a database query. You can freely define the query yourself and extend it with variables. |
Required licence | Database Feature |
1 | Database | Select the database on which the query is to be executed. |
2 | SQL-Query | Enter the SQL query here. It is recommended to create and test the query in an SQL editor (e.g. SQL Server Management Studio) beforehand. The syntax depends on the type of your database and is not validated by DataSuite at this point. You can also include variables (e.g. from the PLC) in the query (see Use variables). |
3 | Parameter | For each variable you use, you get a selection under the query editor. Variables can be integrated into the query in two ways. Text: The value of the variable is converted into a string and integrated directly into the text of the query. This allows you to select a table through the PLC, for example. The conversion of e.g. numbers into text can lead to display and rounding errors. SQL parameter: In the query, the variable is replaced by an SQL parameter and the value of the variable is passed to the SQL parameter in the original data type. No conversion of the data type takes place in order to avoid display and rounding errors. SQL parameters cannot be used at all points in the query (depending on your database). For example, it is not possible to select the table via an SQL parameter. |