Академический Документы
Профессиональный Документы
Культура Документы
By PenchalaRaju.Yanamala
Transformation type:
Passive
Connected
You can make a Sequence Generator reusable, and use it in multiple mappings.
You might reuse a Sequence Generator when you perform multiple loads to a
single target.
For example, if you have a large input file that you separate into three sessions
running in parallel, use a Sequence Generator to generate primary key values. If
you use different Sequence Generators, the Integration Service might generate
duplicate key values. Instead, use the reusable Sequence Generator for all three
sessions to provide a unique value for each target row.
You can complete the following tasks with a Sequence Generator transformation:
Create keys.
Replace missing values.
Cycle through a sequential range of numbers.
Creating Keys
You can create primary or foreign key values with the Sequence Generator
transformation by connecting the NEXTVAL port to a target or downstream
transformation. You can use a range of values from 1 to
9,223,372,036,854,775,807 with the smallest interval of 1.
When you create primary or foreign keys, use the Cycle option to prevent the
Integration Service from creating duplicate primary keys. You might do this by
selecting the Truncate Target Table option in the session properties or by
creating composite keys.
To create a composite key, you can configure the Integration Service to cycle
through a smaller set of values. For example, if you have three stores generating
order numbers, you might have a Sequence Generator cycling through values
from 1 to 3, incrementing by 1. When you pass the following set of foreign keys,
the generated values then create unique composite keys:
COMPOSITE_KEY ORDER_NO
1 12345
2 12345
3 12345
1 12346
2 12346
3 12346
For example, to replace null values in the ORDER_NO column, you create a
Sequence Generator transformation with the properties and drag the NEXTVAL
port to an Expression transformation. In the Expression transformation, drag the
ORDER_NO port into the transformation along with any other necessary ports.
Then create an output port, ALL_ORDERS.
In ALL_ORDERS, you can then enter the following expression to replace null
orders:
The Sequence Generator transformation has two output ports: NEXTVAL and
CURRVAL. You cannot edit or delete these ports. Likewise, you cannot add ports
to the transformation.
NEXTVAL
T_ORDERS_PRIMARY T_ORDERS_FOREIGN
TABLE: TABLE:
PRIMARY KEY PRIMARY KEY
1 6
2 7
3 8
4 9
5 10
If you want the same values to go to more than one target that receives data
from a single transformation, you can connect a Sequence Generator
transformation to that preceding transformation. The Integration Service
processes the values into a block of sequence numbers. This allows the
Integration Service to pass unique values to the transformation, and then route
rows from the transformation to targets.
Figure 19-1 shows a mapping with a Sequence Generator that passes unique
values to the Expression transformation. The Expression transformation
populates both targets with identical primary key values.
Note: When you run a partitioned session on a grid, the Sequence Generator
transformation skips values depending on the number of rows in each partition.
Sequence Description
Generator
Setting
Start Value Start value of the generated sequence that you want the Integration
Service to use if you use the Cycle option. If you select Cycle, the
Integration Service cycles back to this value when it reaches the
end value.
Default is 0.
Maximum value is 9,223,372,036,854,775,806.
Increment By Difference between two consecutive values from the NEXTVAL
port.
Default is 1.
Maximum value is 2,147,483,647.
End Value Maximum value the Integration Service generates. If the Integration
Service reaches this value during the session and the sequence is
not configured to cycle, the session fails.
Maximum value is 9,223,372,036,854,775,807.
If you connect the NEXTVAL port to a downstream integer port, set
End Value to a value no larger than the integer maximum value. If
the NEXTVAL exceeds the datatype maximum value for the
downstream port, the session fails.
Current Value Current value of the sequence. Enter the value you want the
Integration Service to use as the first value in the sequence. If you
want to cycle through a series of values, the value must be greater
than or equal to the start value and less than the end value.
If the Number of Cached Values is set to 0, the Integration Service
updates the current value to reflect the last-generated value for the
session plus one, and then uses the updated current value as the
basis for the next time you run this session. However, if you use the
Reset option, the Integration Service resets this value to its original
value after each session.
Note: If you edit this setting, you reset the sequence to the new
setting. If you reset Current Value to 10, and the increment is 1, the
next time you use the session, the Integration Service generates a
first value of 10.
Maximum value is 9,223,372,036,854,775,806. The Integration
Service sets the value to NULL if the current value exceeds the
maximum value.
Cycle If enabled, the Integration Service cycles through the sequence
range.
If disabled, the Integration Service stops the sequence at the
configured end value. The Integration Service fails the session with
overflow errors if it reaches the end value and still has rows to
process.
Number of Number of sequential values the Integration Service caches at a
Cached time. Use this option when multiple sessions use the same reusable
Values Sequence Generator at the same time to ensure each session
receives unique values. The Integration Service updates the
repository as it caches each value. When set to 0, the Integration
Service does not cache values.
Default value for a standard Sequence Generator is 0.
Default value for a reusable Sequence Generator is 1,000.
Maximum value is 9,223,372,036,854,775,807.
Reset If enabled, the Integration Service generates values based on the
original current value for each session. Otherwise, the Integration
Service updates the current value to reflect the last-generated value
for the session plus one, and then uses the updated current value
as the basis for the next session run.
Disabled for reusable Sequence Generator transformations.
Tracing Level Level of detail about the transformation that the Integration Service
writes into the session log.
Enter the lowest value in the sequence that you want the Integration Service to
1.use for the Start Value.
2.Enter the highest value to be used for End Value.
3.Select Cycle.
As it cycles, the Integration Service reaches the configured end value for the
sequence, it wraps around and starts the cycle again, beginning with the
configured Start Value.
Increment By
The Current Value property is the value at which the Integration Service starts
creating the sequence for each session. Increment By is the integer the
Integration Service adds to the existing value to create the new value in the
sequence. By default, the Current Value is set to 1, and Increment By is set to 1.
1000
1010
1020
End Value
End Value is the maximum value you want the Integration Service to generate. If
the Integration Service reaches the end value and the Sequence Generator is not
configured to cycle through the sequence, the session fails with the following
error message:
Current Value
The Integration Service uses the current value as the basis for generated values
for each session. To indicate which value you want the Integration Service to use
the first time it uses the Sequence Generator transformation, you must enter that
value as the current value. If you want to use the Sequence Generator
transformation to cycle through a series of values, the current value must be
greater than or equal to Start Value and less than the end value.
At the end of each session, the Integration Service updates the current value to
the last value generated for the session plus one if the Sequence Generator
Number of Cached Values is 0. For example, if the Integration Service ends a
session with a generated value of 101, it updates the Sequence Generator
current value to 102 in the repository. The next time the Sequence Generator is
used, the Integration Service uses 102 as the basis for the next generated value.
If the Sequence Generator Increment By is 1, when the Integration Service starts
another session using the Sequence Generator, the first generated value is 102.
If you have multiple versions of the Sequence Generator transformation, and you
want to reset the sequence, you must check in the mapping or reusable
Sequence Generator transformation after you modify the current value.
Note: If you configure the Sequence Generator to Reset, the Integration Service
uses the current value as the basis for the first generated value for each session.
When you set Number of Cached Values greater than zero, the Integration
Service caches values during the session. At the start of the session, the
Integration Service accesses the repository for the current value, caches the
configured number of values, and updates the current value accordingly. If the
Integration Service uses all values in the cache, it accesses the repository for the
next set of values and updates the current value. At the end of the session, the
Integration Service discards any remaining values in the cache.
When multiple sessions use the same Sequence Generator transformation at the
same time, you risk generating the same values for each session. To avoid this,
have the Integration Service cache a set number of values for each session by
configuring Number of Cached Values.
Reset
If you do not select Reset, the Integration Service updates the current value to
235 at the end of the first session run. The next time it uses the Sequence
Generator transformation, the first value generated is 235.
In the Mapping Designer, click Transformation > Create. Select the Sequence
1.Generator transformation.
The naming convention for Sequence Generator transformations is
SEQ_TransformationName.
2.Enter a name for the Sequence Generator, and click Create. Click Done.
The Designer creates the Sequence Generator transformation.
3.Double-click the title bar of the transformation.
4.Enter a description for the transformation.
5.Select the Properties tab. Enter settings.
For a list of transformation properties, see Sequence Generator Transformation
Properties.
6.Click OK.
To generate new sequences during a session, connect the NEXTVAL port to at
7.least one transformation in the mapping.
Use the NEXTVAL or CURRVAL ports in an expression in other transformations.