Function Reference > Functions > SETVARIABLE
  

SETVARIABLE

Sets the current value of an in-out parameter to a value you specify. Returns the specified value.
During task execution, Informatica Cloud compares the final current value of the in-out parameter to the start value. Based on the aggregate type of the in-out parameter, it saves a final current value to the Activity Log. Unless overridden, it uses the saved value as the initial value of the in-out parameter for the next task run.
Use the SETVARIABLE function only once for each in-out parameter in a pipeline. Informatica Cloud processes variable functions as it encounters them in the mapping. The order in which Informatica Cloud encounters variable functions in the mapping may not be the same for every task session. This could cause inconsistent results if you use the same variable function multiple times in a mapping.
You can use SETVARIABLE in the Expression transformation.

Syntax

SETVARIABLE( $$Variable, value )
Argument
Required/
Optional
Description
$$ Variable
Required
Name of the in-out parameter you want to set. Use with in-out parameters configured with the Max or Min aggregation type.
value
Required
The value to set as the current value of the in-out parameter. You can use a valid expression that evaluates to a datatype compatible with the datatype of the parameter.

Return Value

Current value of the in-out parameter.
When value is NULL, Informatica Cloud returns the current value of $$Variable.

Examples

The following expression sets an in-out parameter $$Time to the system date at the time Informatica Cloud evaluates the row and returns the system date to the SET_$$TIME port:
SETVARIABLE ($$Time, SYSDATE)
TRANSACTION
TOTAL
SET_$$TIME
0100002
534.23
10/10/2016 01:34:33
0100003
699.01
10/10/2016 01:34:34
0100004
97.50
10/10/2016 01:34:35
0100005
116.43
10/10/2016 01:34:36
0100006
323.95
10/10/2016 01:34:37
At the end of the session, Informatica Cloud saves 10/10/2016 01:34:37 to the Activity Log as the last evaluated current value for $$Time. The next time the task runs, Informatica Cloud evaluates all references to $$Time to 10/10/2016 01:34:37.
The following expression sets the in-out parameter $$Timestamp to the timestamp associated with the row and returns the timestamp to the SET_$$TIMESTAMP port:
SETVARIABLE ($$Time, TIMESTAMP)
TRANSACTION
TIMESTAMP
TOTAL
SET_$$TIME
0100002
10/01/2016 12:01:01
534.23
10/01/2016 12:01:01
0100003
10/01/2016 12:10:22
699.01
10/01/2016 12:10:22
0100004
10/01/2016 12:16:45
97.50
10/01/2016 12:16:45
0100005
10/01/2016 12:23:10
116.43
10/01/2016 12:23:10
0100006
10/01/2016 12:40:31
323.95
10/01/2016 12:40:31
At the end of the session, Informatica Cloud saves 10/01/2016 12:40:31 to the Activity Log as the last evaluated current value for $$Timestamp.
The next time the session runs, Informatica Cloud sets the initial value of $$Timestamp to 10/01/2016 12:40:31.