Академический Документы
Профессиональный Документы
Культура Документы
By PenchalaRaju.Yanamala
Transformation type:
Active
Connected
When you design a data warehouse, you need to decide what type of information
to store in targets. As part of the target table design, you need to determine
whether to maintain all the historic data or just the most recent changes.
For example, you might have a target table, T_CUSTOMERS, that contains
customer data. When a customer address changes, you may want to save the
original address in the table instead of updating that portion of the customer row.
In this case, you would create a new row containing the updated address, and
preserve the original row with the old customer address. This shows how you
might store historical information in a target table. However, if you want the
T_CUSTOMERS table to be a snapshot of current customer data, you would
update the existing customer row and lose the original address.
The model you choose determines how you handle changes to existing rows. In
PowerCenter, you set the update strategy at two different levels:
Within a session. When you configure a session, you can instruct the
Integration Service to either treat all rows in the same way (for example, treat all
rows as inserts), or use instructions coded into the session mapping to flag rows
for different database operations.
Within a mapping. Within a mapping, you use the Update Strategy
transformation to flag rows for insert, delete, update, or reject.
Note: You can also use the Multigroup External Procedure transformation to flag
rows for insert, delete, update, or reject.
To control how rows are flagged for insert, update, delete, or reject within a
mapping, add an Update Strategy transformation to the mapping. Update
Strategy transformations are essential if you want to flag rows destined for the
1.same target for different database operations, or if you want to reject rows.
Define how to flag rows when you configure a session. You can flag all rows for
insert, delete, or update, or you can select the data driven option, where the
Integration Service follows instructions coded into Update Strategy
2.transformations within the session mapping.
Define insert, update, and delete options for each target when you configure a
session. On a target-by-target basis, you can allow or disallow inserts and
3.deletes, and you can choose three different ways to handle updates.
Related Topics:
Setting the Update Strategy for a Session
Flagging Rows Within a Mapping
For the greatest degree of control over the update strategy, you add Update
Strategy transformations to a mapping. The most important feature of this
transformation is its update strategy expression, used to flag individual rows for
insert, delete, update, or reject.
The following table lists the constants for each database operation and their
numeric equivalent:
You can configure the Update Strategy transformation to either pass rejected
rows to the next transformation or drop them. By default, the Integration Service
forwards rejected rows to the next transformation. The Integration Service flags
the rows for reject and writes them to the session reject file. If you do not select
Forward Rejected Rows, the Integration Service drops rejected rows and writes
them to the session log file.
If you enable row error handling, the Integration Service writes the rejected rows
and the dropped rows to the row error logs. It does not generate a reject file. If
you want to write the dropped rows to the session log in addition to the row error
logs, you can enable verbose data tracing.
Frequently, the update strategy expression uses the IIF or DECODE function
from the transformation language to test each row to see if it meets a particular
condition. If it does, you can then assign each row a numeric code to flag it for a
particular database operation. For example, the following IIF statement flags a
row for reject if the entry date is after the apply date. Otherwise, it flags the row
for update:
When you create a mapping with a Lookup transformation that uses a dynamic
lookup cache, you must use Update Strategy transformations to flag the rows for
the target tables. When you configure a session using Update Strategy
transformations and a dynamic lookup cache, you must define certain session
properties.
You must define the Treat Source Rows As option as Data Driven. Specify this
option on the Properties tab in the session properties.
You must also define the following update strategy target table options:
Select Insert
Select Update as Update
Do not select Delete
These update strategy target table options ensure that the Integration Service
updates rows marked for update and inserts rows marked for insert.
If you do not choose Data Driven, the Integration Service flags all rows for the
database operation you specify in the Treat Source Rows As option and does not
use the Update Strategy transformations in the mapping to flag the rows. The
Integration Service does not insert and update the correct rows. If you do not
choose Update as Update, the Integration Service does not correctly update the
rows flagged for update in the target table. As a result, the lookup cache and
target table might become unsynchronized.
When you configure a session, you have several options for handling database
operations, including updates.
When you configure a session, you can select a single database operation for all
rows using the Treat Source Rows As setting.
Table 28-1 displays the options for the Treat Source Rows As setting:
Once you determine how to treat all rows in the session, you also need to set
update strategy options for individual targets. Define the update strategy options
in the Transformations view on Mapping tab of the session properties.
Choosing an update strategy requires setting the right options within a session
and possibly adding Update Strategy transformations to a mapping. This section
summarizes what you need to implement different versions of an update
strategy.
When you configure the session, select Insert for the Treat Source Rows As
session property. Also, make sure that you select the Insert option for all target
instances in the session.
When you configure the session, select Delete for the Treat Source Rows As
session property. Also, make sure that you select the Delete option for all target
instances in the session.
Only perform updates on the contents of a target table.
When you configure the session, select Update for the Treat Source Rows As
session property. When you configure the update options for each target table
instance, make sure you select the Update option for each target instance.
Perform different database operations with different rows destined for the same
target table.
Add an Update Strategy transformation to the mapping. When you write the
transformation update strategy expression, use either the DECODE or IIF
function to flag rows for different operations (insert, delete, update, or reject).
When you configure a session that uses this mapping, select Data Driven for the
Treat Source Rows As session property. Make sure that you select the Insert,
Delete, or one of the Update options for each target table instance.
Reject data.
Add an Update Strategy transformation to the mapping. When you write the
transformation update strategy expression, use DECODE or IIF to specify the
criteria for rejecting the row. When you configure a session that uses this
mapping, select Data Driven for the Treat Source Rows As session property.