Вы находитесь на странице: 1из 9

BANGALORE TECHNICAL TRAININGS Onlinetrainingsbglr@gmail.

com +917411642061

Lab 11
Incremental Update

Lab at a Glance................................................................2 Objectives..............................................................2 Summary................................................................2 Duration.................................................................2 Exercises..........................................................................3 Exercise 1: Import Sources and Targets................3 Exercise 2: Create the Mapping.............................5 Exercise 3: Create and Run the Workflow..............8

PowerCenter 9.x Level I Developer Lab Guide

11 - 1

Lab 11. Incremental Update

Lab at a Glance
The exercises in this lab are designed to walk the student through the process of using a Lookup transformation and an Update Strategy transformation to do an incremental update.

Objectives
After completing the lab, the student will be able to: Create and configure a Lookup and Update Strategy transformation to perform an incremental table update.

Summary
The purpose of this lab is to pull information from the PRODUCT and VENDOR source tables to create an ODS_PRODUCT table that has information about the equipment and supplies that the company resells to customers. The ODS_PRODUCT table will be updated to keep only the most current product information - only equipment and supplies that are currently available. All discontinued products will be removed from the table. The completed mapping should look as follows:

Duration
This lab should take approximately 40 minutes.

11 - 2

PowerCenter 9.x Level I Developer Lab Guide

Lab 11. Incremental Update

Exercises
Exercise 1: Import Sources and Targets
Step 1. Import source tables. Continue to work in the assigned student folder Clear the Source Analyzer workspace by right-clicking anywhere in the work area and selecting Clear All. Import the PRODUCT and VENDOR relational tables from the SDBU database schema. When importing the PRODUCT table, the Table Exists dialog is displayed:

Replacing the PRODUCT source will invalidate any mappings already using it. The invalid mappings will appear in the navigator with a red x icon. In a real world scenario, they will require revalidating. For purposes of these labs, dont worry about those mappings; they will not be used again.

Click on the Replace button to replace the PRODUCT table. The tables are displayed in the workspace:

PowerCenter 9.x Level I Developer Lab Guide

11 - 3

Lab 11. Incremental Update

Step 2. Import the target table. Clear the Warehouse Designer workspace by rightclicking anywhere in the work area and selecting Clear All. Import the ODS_PRODUCT relational target from the TDBUxx database schema.

11 - 4

PowerCenter 9.x Level I Developer Lab Guide

Lab 11. Incremental Update

Exercise 2: Create the Mapping


Step 1. Create a mapping. Create a mapping and name it m_ODS_PRODUCT_xx. Add the PRODUCT and VENDOR source definitions. Add the ODS_PRODUCT target definition. Save the repository. Step 2. Create a Source Qualifier. There is a primary key foreign key relationship between the two source tables. To take advantage of the relationship, only
one Source Qualifier is necessary. The Source Qualifier will pass the where clause to the database at runtime to join the tables.

If present, delete the two Source Qualifiers that were automatically created. Create a new Source Qualifier by selecting both sources (PRODUCT and VENDOR) and name it sq_PRODUCT_VENDOR.

PowerCenter 9.x Level I Developer Lab Guide

11 - 5

Lab 11. Incremental Update

Step 3. Create a Lookup transformation (connected). Add a Lookup transformation to the mapping.

The Select Lookup Table for Lookup Transformation dialog box appears. Click the Target button and select the ODS_PRODUCT table to be the lookup table.

Click OK.
Appending _src to a port states it came from the source and not from the Lookup. Never change the name of a port that has the Lookup (L) port checked. Lookup ports are the ports that will be used in the SQL select statement sent to the database. If a column is renamed, a database error will occur at session runtime.

Copy/link PRODUCT_CODE from sq_PRODUCT_VENDOR to the Lookup transformation. Rename the Lookup transformation
lkp_ODS_PRODUCT.

Rename the port PRODUCT_CODE1, which came from sq_PRODUCT_VENDOR, to PRODUCT_CODE_src. Turn off the O (output) attribute for: VENDOR_ID,
CATEGORY, MODEL, PRICE VENDOR_NAME, VENDOR_STATE, PRODUCT_NAME,

and FIRST_CONTACT.

Un-checking the Output attribute prevents columns from being unnecessarily cached. This can be done for those ports that are not needed for the condition and will not be used downstream in another transformation. Add the following lookup condition: PRODUCT_CODE = PRODUCT_CODE_src Click the OK button and save the repository.

11 - 6

PowerCenter 9.x Level I Developer Lab Guide

Lab 11. Incremental Update

Step 4. Create an update strategy transformation. Create an Update Strategy transformation and name it upd_ODS_PRODUCT. Copy/Link PRODUCT_CODE and PRODUCT_CODE_src from lkp_ODS_PRODUCT to upd_ODS_PRODUCT. Copy/Link VENDOR_ID, CATEGORY, PRODUCT_NAME, MODEL, PRICE, DISCONTINUED FLAG, VENDOR_NAME, FIRST_CONTACT, and VENDOR_STATE from sq_PRODUCT_VENDOR to upd_ODS_PRODUCT. Rename the PRODUCT_CODE port, which came from lkp_ODS_PRODUCT, to PRODUCT_CODE_lkp. Click on the Properties tab. Add the following expression: IIF(ISNULL(PRODUCT_CODE_lkp), IIF(DISCONTINUED_FLAG = 0, DD_INSERT, DD_REJECT), IIF(DISCONTINUED_FLAG = 0, DD_UPDATE, DD_DELETE))
With the Forward Rejected Rows selected, the Informatica Server forwards the rows to the next transformation, then flags the rows for reject and ultimately writes them to the session reject file. When not selected, the Informatica Server drops rejected rows and writes them to the session log file.

On the Properties tab, uncheck the Forward Rejected Rows checkbox:

This keeps rejected rows from being forwarded through the mapping. They drop instead to the session log file. Step 5. Link target definition. Connect PRODUCT_CODE_src, VENDOR_ID, CATEGORY, PRODUCT_NAME, MODEL, PRICE, VENDOR_NAME, FIRST_CONTACT, and VENDOR_STATE from upd_ODS_PRODUCT to ODS_PRODUCT. For example, use autolink by name specifying the From suffix _src. Save the repository.

PowerCenter 9.x Level I Developer Lab Guide

11 - 7

Lab 11. Incremental Update

Exercise 3: Create and Run the Workflow


Step 1. Create a workflow. Create a workflow called wf_ODS_PRODUCT_xx. Create a session task in the workflow called s_m_ODS_PRODUCT_xx. Double-click on the session task. The Edit Tasks dialog box appears.

In the Properties tab, set the Treat source rows as option to Data Driven. Select the Mapping tab. In the Navigator window, select the source
SQ_PRODUCT_VENDOR.

Under Connections, click on the down arrow native_source and click OK.

, select

In the Navigator window, select the target ODS_PRODUCT. Under Connections, click on the down arrow , select native_target_xx (where xx represents the assigned student number) and click OK. Under Properties, the Target load type should be defaulted to Normal. (Leave the Truncate target table option checkbox unchecked.)

Click OK to close the Edit Tasks dialog box.

Link Start to s_m_ODS_PRODUCT_xx:

Save, validate and start wf_ODS_PRODUCT_xx. Monitor and review the results for s_m_ODS_PRODUCT_xx in the Workflow Monitor.

11 - 8

PowerCenter 9.x Level I Developer Lab Guide

Lab 11. Incremental Update

Step 2. Verify results session properties.

Step 3. Verify results session transformation statistics.

If the Forward Reject Rows checkbox was checked, 3 rows would have been rejected:

Step 4. Verify results preview data.


Note that only the first few rows are shown here.

ODS_PRODUCT

PowerCenter 9.x Level I Developer Lab Guide

11 - 9

Вам также может понравиться