When you declare a mapping variable in a mapping, you need to configure the datatype and aggregation type for the variable.
The datatype you choose for a mapping variable allows the Integration Service to pick an appropriate default value for the mapping variable. The default is used as the start value of a mapping variable when there is no value defined for a variable in the parameter file, in the repository, and there is no user defined initial value.
The Integration Service uses the aggregate type of a mapping variable to determine the final current value of the mapping variable. When you have a pipeline with multiple partitions, the Integration Service combines the variable value from each partition and saves the final current variable value into the repository.
You can create a variable with the following aggregation types:
You can configure a mapping variable for a Count aggregation type when it is an Integer or Small Integer. You can configure mapping variables of any datatype for Max or Min aggregation types.
To keep the variable value consistent throughout the session run, the Designer limits the variable functions you use with a variable based on aggregation type. For example, use the SetMaxVariable function for a variable with a Max aggregation type, but not with a variable with a Min aggregation type.
The following table describes the available variable functions and the aggregation types and datatypes you use with each function:
| | All transformation datatypes except binary datatype. |
| | All transformation datatypes except binary datatype. |
| | All transformation datatypes except binary datatype. |
| | Integer and small integer datatypes only. |
For multiple target load order groups, the mapping variable value in a target load order group depends on the variable aggregation type and the variable value in the previous target load order group. After every target load order group runs, the Integration Service calculates the mapping variable values to use in the next target load order group based on the variable aggregation type.
For example, a session contains two target load order groups. You have set Max as the aggregation type of the mapping variable.
When the first target load order group runs, you have set the following different values using the SetVariable function for the mapping variable, $$MAPVAR:
SetVariable($$MAPVAR,20)
SetVariable($$MAPVAR,10)
SetVariable($$MAPVAR,60)
SetVariable($$MAPVAR,30)
At the end of the first target load order group run, the Integration Service calculates the Max of all the four values of $$MAPVAR. As the Max of the four values is 60, so the Integration Service uses 60 as the initial value of the mapping variable, $$MAPVAR, in the next target load order group.