Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions
  8. Creating Custom Functions
  9. Custom Function API Reference

Transformation Language Reference

Transformation Language Reference

SETMAXVARIABLE

SETMAXVARIABLE

Sets the current value of a mapping variable to the higher of two values: the current value of the variable or the value you specify. Returns the new current value. The function executes only if a row is marked as insert. SETMAXVARIABLE ignores all other row types and the current value remains unchanged.
At the end of a successful session, the
PowerCenter Integration Service
saves the final current value to the repository. When used with a session that contains multiple partitions, the
PowerCenter Integration Service
generates different current values for each partition. At the end of the session, it saves the highest current value across all partitions to the repository. Unless overridden, it uses the saved value as the initial value of the variable for the next session run.
When used with a string mapping variable, SETMAXVARIABLE returns the higher string based on the sort order selected for the session.
Use the SETMAXVARIABLE function only once for each mapping variable in a pipeline. The
PowerCenter Integration Service
processes variable functions as it encounters them in the mapping. The order in which the
PowerCenter Integration Service
encounters variable functions in the mapping may not be the same for every session run. This can cause inconsistent results when you use the same variable function multiple times in a mapping.
Use SETMAXVARIABLE with mapping variables with a Max aggregation type. Use SETMAXVARIABLE in the following transformations:
  • Expression
  • Filter
  • Router
  • Update Strategy
The
PowerCenter Integration Service
does not save the final value of a mapping variable to the repository when any of the following conditions are true:
  • The session fails to complete.
  • The session is configured for a test load.
  • The session is a debug session.
  • The session runs in debug mode and is configured to discard session output.

Syntax

SETMAXVARIABLE( $$
Variable
,
value
)
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
$$
Variable
Required
Name of the mapping variable you want to set. Use mapping variables with Max aggregation type.
value
Required
The value you want the
PowerCenter Integration Service
to compare against the current value of the variable. You can enter any valid transformation expression that evaluates to a datatype compatible with the datatype of the variable.

Return Value

The higher of two values: the current value of the variable or the value you specified. The return value is the new current value of the variable.
When
value
is NULL the
PowerCenter Integration Service
returns the current value of
$$Variable
.

Examples

The following expression compares the number of items purchased in each transaction with a mapping variable $$MaxItems. It sets $$MaxItems to the higher of two values and returns the historically highest number of items purchased in a single transaction to the MAX_ITEMS port. The initial value of $$MaxItems from the previous session run is 22.
SETMAXVARIABLE ($$MAXITEMS, ITEMS)
TRANSACTION
ITEMS
MAX_ITEMS
0100002
12
22
0100003
5
22
0100004
18
22
0100005
35
35
0100006
5
35
0100007
14
35
At the end of the session, the
PowerCenter Integration Service
saves ‘35’ to the repository as the maximum current value for $$MaxItems. The next time the session runs, the
PowerCenter Integration Service
evaluates the initial value to $$MaxItems to ‘35’.
If the same session contains three partitions, the
PowerCenter Integration Service
evaluates $$MaxItems for each partition. Then, it saves the largest value to the repository. For example, the last evaluated value for $$MaxItems in each partition is as follows:
Partition
Final Current Value for $$MaxItems
Partition 1
35
Partition 2
23
Partition 3
22

0 COMMENTS

We’d like to hear from you!