Workflow Variables Overview:
You can create and use variables in a workflow to reference values and record information. For example, use a Variable in a Decision task to determine whether the previous task ran properly. If it did, you can run the next task.
If not, you can stop the workflow. Use the following types of workflow variables:
- Predefined workflow variables. The Workflow Manager provides predefined workflow variables for tasks within a workflow.
- User-defined workflow variables. You create user-defined workflow variables when you create a workflow. Use workflow variables when you configure the following types of tasks:
- Assignment tasks. Use an Assignment task to assign a value to a user-defined workflow variable. For Example, you can increment a user-defined counter variable by setting the variable to its current value plus 1.
- Decision tasks. Decision tasks determine how the Integration Service runs a workflow. For example, use the Status variable to run a second session only if the first session completes successfully.
- Links. Links connect each workflow task. Use workflow variables in links to create branches in the workflow. For example, after a Decision task, you can create one link to follow when the decision condition evaluates to true, and another link to follow when the decision condition evaluates to false.
- Timer tasks. Timer tasks specify when the Integration Service begins to run the next task in the workflow. Use a user-defined date/time variable to specify the time the Integration Service starts to run the next task.
Use the following keywords to write expressions for user-defined and predefined workflow variables:
- AND
- OR
- NOT
- TRUE
- FALSE
- NULL
- SYSDATE
Predefined Workflow Variables:
Each workflow contains a set of predefined variables that you use to evaluate workflow and task conditions. Use the following types of predefined variables:
- Task-specific variables. The Workflow Manager provides a set of task-specific variables for each task in the workflow. Use task-specific variables in a link condition to control the path the Integration Service takes when running the workflow. The Workflow Manager lists task-specific variables under the task name in the Expression Editor.
- Built-in variables. Use built-in variables in a workflow to return run-time or system information such as folder name, Integration Service Name, system date, or workflow start time. The Workflow Manager lists built-in variables under the Built-in node in the Expression Editor.
Task-Specific | Description | Task Types | Data type |
Condition | Evaluation result of decision condition expression.
| Decision | Integer |
End Time | Date and time the associated task ended. Precision is to the second. | All tasks | Date/Time |
ErrorCode | Last error code for the associated task. If there is no error, the Integration Service sets ErrorCode to 0 when the task completes. | All tasks | Integer |
ErrorMsg | Last error message for the associated task.If there is no error, the Integration Service sets ErrorMsg to an empty string when the task completes. | All tasks | Nstring |
First Error Code | Error code for the first error message in the session. | Session | Integer |
FirstErrorMsg | First error message in the session.If there is no error, the Integration Service sets FirstErrorMsg to an empty string when the task completes. | Session | Nstring |
PrevTaskStatus | Status of the previous task in the workflow that the Integration Service ran. Statuses include: | All Tasks | Integer |
SrcFailedRows | Total number of rows the Integration Service failed to read from the source. | Session | Integer |
SrcSuccessRows | Total number of rows successfully read from the sources. | Session | Integer |
StartTime | Date and time the associated task started. Precision is to the second. | All Task | Date/Time |
Status | Status of the previous task in the workflow. Statuses include: | All Task | Integer |
TgtFailedRows | Total number of rows the Integration Service failed to write to the target. | Session | Integer |
TgtSuccessRows | Total number of rows successfully written to the target. | Session | Integer |
TotalTransErrors | Total number of transformation errors. | Session | Integer |
User-Defined Workflow Variables:
You can create variables within a workflow. When you create a variable in a workflow, it is valid only in that workflow. Use the variable in tasks within that workflow. You can edit and delete user-defined workflow variables.
Use user-defined variables when you need to make a workflow decision based on criteria you specify. For example, you create a workflow to load data to an orders database nightly. You also need to load a subset of this data to headquarters periodically, every tenth time you update the local orders database. Create separate sessions to update the local database and the one at headquarters.
Use a user-defined variable to determine when to run the session that updates the orders database at headquarters.
To configure user-defined workflow variables, complete the following steps:
1. Create a persistent workflow variable, $$WorkflowCount, to represent the number of times the workflow has run.
2. Add a Start task and both sessions to the workflow.
3. Place a Decision task after the session that updates the local orders database.Set up the decision condition to check to see if the number of workflow runs is evenly divisible by 10. Use the modulus (MOD) function to do this.
4. Create an Assignment task to increment the $$WorkflowCount variable by one.
5. Link the Decision task to the session that updates the database at headquarters when the decision condition evaluates to true. Link it to the Assignment task when the decision condition evaluates to false. When you configure workflow variables using conditions, the session that updates the local database runs every time the workflow runs. The session that updates the database at headquarters runs every 10th time the workflow runs.
Creating User-Defined Workflow Variables :
You can create workflow variables for a workflow in the workflow properties.
To create a workflow variable:
1. In the Workflow Designer, create a new workflow or edit an existing one.
2. Select the Variables tab.
3. Click Add.
4. Enter the information in the following table and click OK:
Field | Description |
Name | Variable name. The correct format is $$VariableName. Workflow variable names are not case sensitive. |
Data type | Data type of the variable. You can select from the following data types: |
Persistent | Whether the variable is persistent. Enable this option if you want the value of the variable |
Default Value | Default value of the variable. The Integration Service uses this value for the variable during |
Is Null | Whether the default value of the variable is null. If the default value is null, enable this option. |
Description | Description associated with the variable. |
5. To validate the default value of the new workflow variable, click the Validate button.
6. Click Apply to save the new workflow variable.
7. Click OK.
No comments:
Post a Comment