SEC_SQL VARA Objects
SEC_SQL (Secure SQL) VARA objects retrieve values from external databases in a secure manner. SEC_SQL VARA objects are similar to SQL VARA objects because they also run SQL statements on an external database. As opposed to SQL VARA objects, with SEC_SQL you can use all supported variables within SQL statements without putting the database at risk of an SQL injection.
The variables are replaced regardless of the VAR_SECURITY_LEVEL settings in the UC_SYSTEM_SETTINGS - Systemwide Settings variable.
Recommendations
-
For technical reasons, the system cannot check whether only SELECT commands are used in the variable's SQL. To prevent that SQL commands other that SELECT are run, deploy a database user with read-only access rights.
-
SEC_SQL VARA objects require a DB Service Agent that was started in DB service mode and that is version v9 SP3 or later. Older Agents do not support this VARA type. For more information, see Installing the Agent for Database Variables.
Restriction
This type of VARA object does not support binary fields. Binary data that result from an SQL query causes an error in the preview or when the values are retrieved at runtime.
Notes
- The maximum number of returned lines is specified in the SQLVAR_MAX_ROWS setting in the UC_SYSTEM_SETTINGS variable.
-
Depending on the data type, this VARA object returns "" (string, date, time, timestamp) or 0 (number) for NULL values.
-
Use PromptSet variables here when you use the Dynamic Reload feature for combo box prompts. The PromptSet variables are resolved when the object that includes the PromptSet is executed.
-
In the Variables Settings and Bind Parameters sections:
You can include PromptSet variables here when using the dynamic reload feature for combo box prompts. When you use PromptSet variables in a dynamic VARA object, the Preview feature returns an error. This is because the PromptSet variables do not exist in the dynamic VARA object. However, the PromptSet variables will be resolved when objects including the PromptSet are executed.
A SEC_SQL VARA object definition is made up of the following pages:
-
Common to all object types, here you define basic object information and apply custom values to it
-
Variables
Here you define the object-specific settings. Some sections on this page are common to all VARA objects and are described for all of them in dedicated topics:
- Variable Settings, see below
- Bind Parameters, see below
- Data Types and Formatting
- Script Access
- Client 0 VARA Objects in Other Clients
- Preview, see below
-
Common to all object types, here you find a list of all versions of the object
-
Common to all object types, here you enter information that you consider important to understand the configuration and behavior of the object
To Define a SEC_SQL VARA Object
-
In the Variable Settings section, specify the following:
-
Type
Read-only, always SEC_SQL
-
Connection
Connection object of type Database that contains the connection parameters for the selected database.
To be able to use PromptSet variables here, the VAR_SECURITY_LEVEL system variable must be set to 3. For more information, see VAR_SECURITY_LEVEL.
-
Login
Login object that stores the name and password of the database user. If you neither specify a Login object nor set the option Default login, the login data for accessing the database is retrieved from the Connection object.
To be able to use PromptSet variables here, the VAR_SECURITY_LEVEL system variable must be set to 3. For more information, see VAR_SECURITY_LEVEL.
-
Default Login
Default Login object that is assigned to your user definition. If your user definition has no Login object assigned, an error occurs. If you select this option, the Login object that is specified in the VARA object is ignored.
PromptSet variables cannot be used here.
-
SQL Statement
SQL statements used to select specific database entries that serve as variable values. Variables that are directly specified in SQL are replaced.
For technical reasons, the system does not check the SQL statements that are processed with database VARA objects (SEC_SQLI, SEC_SQL, SQLI, and SQL types). This means that you can change or delete data records by using VARA objects. For security reasons, consider restricting user access accordingly. If possible, deploy a database user with read-only rights for VARA objects that can access an external database (SQL, SQL SECURE). For internal SQL variables (SQLI, SQLI SECURE), you can limit object access via a privilege (create and modify SQL-internal variables).
You cannot specify the variables here, but you can include them using bind parameters. These bind parameters are maintained in the related tables and can include predefined variables, placeholders for VARA objects and PromptSet variables. In the SQL script, use the "?" character in the locations where the bind parameters will be inserted.
Maximum length: 4096 characters
-
-
You insert variable values within SQL statements in the Bind Parameters section. You can use variable or VARA object names as bind parameters with any values of your choice. If a variable or VARA object does not exist, no values are replaced but the variable or VARA object name is used. This can cause an error when the variable or VARA object is resolved.
You can enter the following type of variables and VARA objects:
- Script variables
- Object variables
- Predefined variables
- Predefined and user-defined VARA objects
Each line in the table represents one bind parameter.
Supported Data Types and Input Formats
- Date: yyyy-mm-dd
- Time: hh:mm:ss
- Timestamp: yyyy-mm-dd hh:mm:ss
- String: any string
- Boolean: possible values: 0 / 1 or true / false
- Number: no thousand separator, a decimal point as a decimal separator
Important!
- Data types are not converted (no conversion from timestamp to date)
- Inserting an invalid value causes an error when the SQL commands are processed
- The VAR_SECURITY_LEVEL variable does not impose any limitations
- In the SQL statements, you must use a "?" character at every location where the replaced value of a bind parameter should be inserted. A bind parameter must exist for each "?". Ensure that you maintain the correct order (table).
- You cannot use bind parameters multiple times
-
Define the Data Types and Formatting.
-
Define the Script Access.
-
To run a command, select it and click Preview. The statements are executed and their results displayed. The preview function serves to check for potential errors in the database statements (for example, it the data type of the VARA object and of the database do not match).
The database Agent sends the preview data to the Automation Engine in the form of a message. If this message exceeds the maximum message length that a server process accepts, an error occurs.
Maximum length: Set in the MaxMsgSize= parameter of the Automation EngineUCSRV.INI file.
Default value: 3145 728 bytes.
-
To export the content of the preview table to a CSV file, click Export Table. All rows and column are exported. Use this function if you need to further process the content of the CSV file (paste it to a different application for further processing and so on).
-
To copy one or more rows in the Preview table, select the Copy button. The selected rows are copied to the clipboard and you can paste them to a third party tool (Google, Sheets, Excel, text editor, and so on).
Note: This function is available only if
https
is used on the Automic Web Interface . -
Save your changes.
See also: