To enhance the flexibility of tasks, SQLMessenger supports the use of variables within tasks. For example, you can utilize variables to change email subjects, email body content, recipient email addresses, and query conditions in SQL statements during task execution.
There are two types of variables in SQLMessenger:
User Variables |
Variables customized by users. The variable name must only contain underscores, letters, and numbers. The variable value can be a fixed value or dynamically determined using SQL statements during task execution. |
System Variables |
System-predefined variables. The variable name starts with the "@@" characters. |
Variables customized by users. The variable name must only contain underscores, letters, and numbers. The variable value can be a fixed value or dynamically determined using SQL statements during task execution.
You can create task variables within a task, which are available throughout the scope of the task. You can also create template variables in an attachment template, which are available within the scope of the corresponding template.
Create task variable
Create template variable
Variable Attributes dialog box
In this dialog box:
Variable Name |
Enter the name of the variable here. The variable name must only contain underscores, letters, and numbers. In the same context, variable names cannot be duplicated. For example, within the same task, the name of a task variable must be unique, and within the same template, the variable names must also be unique. |
Variable Value Source |
Select the source for the variable value here. The variable value can be a fixed value set during configuration, or it can be dynamically queried using an SQL statement during task execution. |
Value |
If the "Variable Value Source" is "Fixed Value", you can enter a value for the variable here. |
SQL |
If the "Variable Value Source" is "Generated by SQL Query", then you need to enter the SQL query here to retrieve the value of the variable. |
Variable Options:
Use the value of the variable as HTML code if it is used in an HTML template |
If this option is selected, when using this variable in an HTML document (such as the body of an email), the variable value will be inserted directly into the HTML document as HTML code. For example, the value of a variable is "<a href='https://www.sqlmessenger.com'>link to web<a/>": This option is not selected, the variable value will be displayed as plain text This option is selected, the variable value will be displayed as a hyper link |
Allow passing variable value from external interface table |
If this option is selected, the system will allow the value for this variable to be passed in from the TASK_PARAMS field in an external interface table. For example, the following SQL statement will initiate a task with ID 123 and pass a value for the task's variable "UserName":
INSERT INTO sqlmessenger_intf
INSERT INTO sqlmessenger_intf
Note: When passing variable values from the external interface table, the task will use the passed values as the variable values for this run, and the configured values for these variables will be ignored. |
Allow empty value for the variable |
Select whether to allow this variable to have an empty value. If this option is not selected, the task will be aborted when the variable's value is an empty string. |
SQL Security Validation: If the variable is used in SQL statements, conduct a security validation on the variable value |
When this option is selected, the system will perform a security check on the variable's value when it is used in an SQL statement. For example, if the value of variable "Month" is "202401;", the following statement will not be executed:
SELECT *
The value of the variable did not pass the SQL statement's security check To avoid SQL statement execution failures caused by variable values containing special characters, you can modify the SQL query's parameter format to JDBC parameters, for example:
SELECT *
|
For ease of task configuration, the system has predefined some commonly used system variables. The variable names of system variables start with "@@".
Different system variables can be used in different locations within a task. You can view the list of available system variables in the Select Variable dialog box.
View the list of available system variables in the Select Variable dialog box
Tips: The date format returned by date-related variables depends on the date settings of the operating system when SQLMessenger is installed.
System variables and task variables are available within the scope of the entire task, while template variables are only available within the scope of the corresponding attachment template or body template.
5.1 Using Variables in SQL Statements
Using variables in SQL statements
5.2 Using Variables in Email Body Template
Using variables in the email body template
5.3 Using Variables in Email Subject
Using Variables in the email subject
5.4 Using Variables to Dynamically Determine Email Recipients
Using variables to dynamically determine email recipients
Dynamically Set Recipients for the Task
5.5 Using Variables in Attachment File Names
Using variables in attachment file names
5.6 Using Variables in Sheet Names
Using variables in sheet names
5.7 Using Variables as Watermarks in PDF Files
Using variables in sheet names