Power Center lets you
control commit and roll back transactions based on a set of rows that pass
through a Transaction Control transformation. A transaction is the set of rows
bound by commit or roll back rows. You can define a transaction based on a
varying number of input rows. You might want to define transactions based on a
group of rows ordered on a common key, such as employee ID or order entry date.
In Power Center, you
define transaction control at the following levels:
- Within a mapping. Within a
mapping, you use the Transaction Control transformation to define a
transaction. You define transactions using an expression in a Transaction
Control transformation. Based on the return value of the expression, you
can choose to commit, roll back, or continue without any transaction
changes.
- Within a session. When you
configure a session, you configure it for user-defined commit. You can
choose to commit or roll back a transaction if the Integration Service
fails to transform or write any row to the target.
When you run the
session, the Integration Service evaluates the expression for each row that
enters the transformation. When it evaluates a commit row, it commits all rows
in the transaction to the target or targets. When the Integration Service
evaluates a roll back row, it rolls back all rows in the transaction from the
target or targets. If the mapping has a flat file target you can generate an
output file each time the Integration Service starts a new transaction. You can
dynamically name each target flat file.
Properties Tab
On the Properties
tab, you can configure the following properties:
- Transaction control expression
- Tracing level
Enter the transaction
control expression in the Transaction Control Condition field. The transaction
control expression uses the IIF function to test each row against the
condition. Use the following syntax for the expression:
IIF (condition,
value1, value2)
The expression
contains values that represent actions the Integration Service performs based
on the return value of the condition. The Integration Service evaluates the
condition on a row-by-row basis. The return value determines whether the
Integration Service commits, rolls back, or makes no transaction changes to the
row.
When the Integration
Service issues a commit or roll back based on the return value of the
expression, it begins a new transaction. Use the following built-in variables
in the Expression Editor when you create a transaction control expression:
- TC_CONTINUE_TRANSACTION. The Integration
Service does not perform any transaction change for this row. This is the
default value of the expression.
- TC_COMMIT_BEFORE. The Integration
Service commits the transaction, begins a new transaction, and writes the
current row to the target. The current row is in the new transaction.
- TC_COMMIT_AFTER. The Integration
Service writes the current row to the target, commits the transaction, and
begins a new transaction. The current row is in the committed transaction.
- TC_ROLLBACK_BEFORE. The Integration
Service rolls back the current transaction, begins a new transaction, and
writes the current row to the target. The current row is in the new
transaction.
- TC_ROLLBACK_AFTER. The Integration
Service writes the current row to the target, rolls back the transaction,
and begins a new transaction. The current row is in the rolled back
transaction.
If the transaction
control expression evaluates to a value other than commit, roll back, or
continue, the Integration Service fails the session.
Mapping Guidelines
and Validation
Use the following
rules and guidelines when you create a mapping with a Transaction Control
transformation:
- If the mapping includes an XML
target, and you choose to append or create a new document on commit, the
input groups must receive data from the same transaction control point.
- Transaction Control
transformations connected to any target other than relational, XML, or
dynamic MQSeries targets are ineffective for those targets.
- You must connect each target
instance to a Transaction Control transformation.
- You can connect multiple targets
to a single Transaction Control transformation.
- You can connect only one effective
Transaction Control transformation to a target.
- You cannot place a Transaction
Control transformation in a pipeline branch that starts with a Sequence
Generator transformation.
- If you use a dynamic Lookup
transformation and a Transaction Control transformation in the same
mapping, a rolled-back transaction might result in unsynchronized target
data.
- A Transaction Control
transformation may be effective for one target and ineffective for another
target. If each target is connected to an effective Transaction Control
transformation, the mapping is valid.
- Either all targets or none of the
targets in the mapping should be connected to an effective Transaction
Control transformation.
Example to
Transaction Control:
Step 1: Design the mapping.
Step 2: Creating a
Transaction Control Transformation.
- In the Mapping Designer, click
Transformation > Create. Select the Transaction Control transformation.
- Enter a name for the
transformation.[ The naming convention for Transaction Control
transformations is TC_TransformationName].
- Enter a description for the
transformation.
- Click Create.
- Click Done.
- Drag the ports into the
transformation.
- Open the Edit Transformations
dialog box, and select the Ports tab.
Select the Properties
tab. Enter the transaction control expression that defines the commit and roll
back behavior.
Go to the Properties
tab and click on the down arrow to get in to the expression editor window.
Later go to the Variables tab and Type IIF(EMpno=7654,) select the below things
from the built in functions.
IIF
(EMPNO=7654,TC_COMMIT_BEFORE,TC_CONTINUE_TRANSACTION)
- Connect all the columns from the
transformation to the target table and save the mapping.
- Select the Metadata Extensions
tab. Create or edit metadata extensions for the Transaction Control
transformation.
- Click OK.
Step 3: Create the task and
the work flow.
Step 4: Preview the
output in the target table.
No comments:
Post a Comment