You are on page 1of 2

Configuring the Target Update Override:

By default, the Integration Service updates target tables based on key values. However, you can
override the default UPDATE statement for each target in a mapping. You might want to update the
target based on non-key columns.

When the Integration Service executes SQL against a source, target, or lookup database, it searches
the reserved words file stored in the Integration Service installation directory. It encloses matching
reserved words in quotes. If you use target update override, you must manually put all reserved words
in quotes.

For a mapping without an Update Strategy transformation or a Custom transformation with the update
strategy property enabled, configure the session to mark source rows as update. The Target Update
option only affects source rows marked as update. The Integration Service processes all rows marked
as insert, delete, or reject normally. When you configure the session, mark source rows as data-driven.
The Target Update Override only affects source rows marked as update by the Update Strategy or
Custom transformation.

For example, a mapping passes the total sales for each salesperson to the T_SALES table.

The Designer generates the following default UPDATE statement for the target T_SALES:

UPDATE T_SALES SET EMP_NAME = :TU.EMP_NAME, DATE_SHIPPED = :TU.DATE_SHIPPED,


TOTAL_SALES = :TU.TOTAL_SALES WHERE EMP_ID = :TU.EMP_ID

Because the target ports must match the target column names, the update statement includes the
keyword:TU to specify the ports in the target transformation. If you modify the UPDATE portion of the
statement, be sure to use :TU to specify ports.

Overriding the WHERE Clause

You can override the WHERE clause to include non-key columns. For example, you might want to
update records for employees named Mike Smith only. To do this, you edit the WHERE clause as
follows:

UPDATE T_SALES SET DATE_SHIPPED = :TU.DATE_SHIPPED,


TOTAL_SALES = :TU.TOTAL_SALES WHERE :TU.EMP_NAME = EMP_NAME and
EMP_NAME = 'MIKE SMITH'

Rules and Guidelines

Use the following rules and guidelines when you enter target update queries:

If you use target update override, you must manually put all database reserved words in quotes.
You cannot override the default UPDATE statement if the target column name contains any of the
following characters:

' , ( ) < > = + - * / \ t \ n \ 0 <space>

You can use parameters and variables in the target update query. Use any parameter or variable type
that you can define in the parameter file. You can enter a parameter or variable within the UPDATE
statement, or you can use a parameter or variable as the update query. For example, you can enter a
session parameter, $ParamMyOverride, as the update query, and set $ParamMyOverride to the
UPDATE statement in a parameter file.
When you save a mapping, the Designer verifies that you have referenced valid port names. It does
not validate the SQL.
If you update an individual row in the target table more than once, the database only has data from
the last update. If the mapping does not define an order for the result data, different runs of the
mapping on identical input data may result in different data in the target table.
A WHERE clause that does not contain any column references updates all rows in the target table, or
no rows in the target table, depending on the WHERE clause and the data from the mapping. For
example, the following query sets the EMP_NAME to “MIKE SMITH” for all rows in the target table if
any row of the transformation has EMP_ID > 100:

UPDATE T_SALES set EMP_NAME = 'MIKE SMITH' WHERE :TU.EMP_ID > 100

If the WHERE clause contains no port references, the mapping updates the same set of rows for each
row of the mapping. For example, the following query updates all employees with EMP_ID > 100 to
have the EMP_NAME from the last row in the mapping:

UPDATE T_SALES set EMP_NAME = :TU.EMP_NAME WHERE EMP_ID > 100

If the mapping includes an Update Strategy or Custom transformation, the Target Update statement
only affects records marked for update.
If you use the Target Update option, configure the session to mark all source records as update.

Steps to Enter a Target Update Statement

Use the following procedure to create an update statement.

To enter a target update statement:

1
. Double-click the title bar of a target instance.
2
. Click Properties.
3
. Click the Open button in the Update Override field.
The SQL Editor displays.
4
. Select Generate SQL.
The default UPDATE statement appears.
5
. Modify the update statement.
You can override the WHERE clause to include non-key columns.
Enclose all reserved words in quotes.
6
. Click OK.
The Designer validates the SQL when you save the mapping.

You might also like