11 transaction control

Upload: vivek-bansal

Post on 04-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 11 Transaction Control

    1/4

    Transaction Control

    TRANSACTION CONTROL TRANSFORMATION IN INFORMATICA

    Transaction Control is an activeand connected transformation.

    The transaction control transformation is used to control the commit and rollback of transactions.

    In Informatica, you define transaction control at the following levels:

    Within a mapping.Within a mapping, you use the Transaction Control transformation todefine 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, rollback, 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 totransform or write any row to the target.

    When you run a session, the integration service evaluates the expression for each row in the transaction

    control transformation. When it evaluates the expression as commit, then it commits all the rows in thetransaction to the target(s). When the integration service evaluates the expression as rollback, then it roll

    back all the rows in the transaction from the target(s).

    When you have flat file as the target, then the integration service creates an output file for each time itcommits the transaction. You can dynamically name the target flat files. Look at the example for creating

    flat files dynamically - Dynamic flat file creation.

    Creating Transaction Control TransformationFollow the below steps to create transaction control transformation:

    Go to the mapping designer, click on transformation in the toolbar, Create. Select the transaction control transformation, enter the name and click on Create and then Done. You can drag the ports in to the transaction control transformation Go to the properties tab. Enter the transaction control expression in the Transaction Control

    Condition.

    http://1.bp.blogspot.com/-I5NNjMcL2fE/T5kXAD4vv0I/AAAAAAAAAW4/mpqpdyVUjLg/s1600/transaction_control_transofrmation.jpg
  • 8/13/2019 11 Transaction Control

    2/4

    Configuring Transaction Control Transformation

    You can configure the following components in the transaction control transformation:

    Transformation Tab:You can rename the transformation and add a description. Ports Tab:You can create input/output ports Properties Tab:You can define the transaction control expression and tracing level. Metadata Extensions Tab:You can add metadata information.

    Transaction Control Expression

    You can enter the transaction control expression in the Transaction Control Condition option inthe properties tab.

    The transaction control expression uses the IIF function to test each row against the condition.

    Use the following syntax for the expressionSyntax:

    IIF (condition, value1, value2)

    Example:

    IIF(dept_id=10, TC_COMMIT_BEFORE,TC_ROLLBACK_BEFORE)

    Use the following built-in variables in the expression editor of the transaction control transformation:

    TC_CONTINUE_TRANSACTION: The Integration Service does not perform any transactionchange for this row. This is the default value of the expression.

    TC_COMMIT_BEFORE:The Integration Service commits the transaction, begins a newtransaction, 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 thetransaction, 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 anew 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 backtransaction.

    If the transaction control transformation evaluates to a value other than the commit, rollback orcontinue, then the integration service fails the session.

  • 8/13/2019 11 Transaction Control

    3/4

    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 Controltransformation.

    Enter a name for the transformation.[ The naming convention for Transaction Controltransformations 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: Previewthe output in the target table.

    http://3.bp.blogspot.com/-1Rxw7utWvoI/TrvC2bS0-5I/AAAAAAAAAcs/b9dWRGU3NZg/s1600/trancont2.jpghttp://2.bp.blogspot.com/-6APFqyAW3Gs/TrvC4ZqRWZI/AAAAAAAAAc8/eviXMiIOF_U/s1600/trancontr1.jpghttp://3.bp.blogspot.com/-1Rxw7utWvoI/TrvC2bS0-5I/AAAAAAAAAcs/b9dWRGU3NZg/s1600/trancont2.jpghttp://2.bp.blogspot.com/-6APFqyAW3Gs/TrvC4ZqRWZI/AAAAAAAAAc8/eviXMiIOF_U/s1600/trancontr1.jpg
  • 8/13/2019 11 Transaction Control

    4/4

    http://4.bp.blogspot.com/-FNX0F4ji9QE/TrvC3Z_revI/AAAAAAAAAc0/wGrXiLKz3sU/s1600/trancont3.jpg