Sunteți pe pagina 1din 8

BANGALORE TECHNICAL TRAININGS Onlinetrainingsbglr@gmail.

com +917411642061

Lab 10
Data-Driven Operations

Lab at a Glance................................................................2 Objectives..............................................................2 Summary................................................................2 Duration.................................................................2 Exercises..........................................................................3 Exercise 1: Create the Mapping.............................3 Exercise 2: Create and Run the Workflow..............5 Exercise 3: Extra Credit..........................................7

PowerCenter 9.x Level I Developer Lab Guide

10 - 1

Lab 10. Data-Driven Operations

Lab at a Glance
The exercises in this lab are designed to walk the student through the process of creating and configuring an Update Strategy transformation.

Objectives
After completing the lab, the student will be able to create and configure an Update Strategy transformation to perform multiple types of row operations within a single session.

Summary
In the previous labs, all of the inactive customers were filtered out to create data in the ODS_CUSTOMER_ACTIVE table. In the CUSTOMER table, the CUSTOMER_TYPE column can be set to either INACTIVE or ACTIVE. Because customers may change from ACTIVE to INACTIVE, Labs 8 and 9 would have to be run every time the ODS_CUSTOMER_ACTIVE table is loaded. The use of an Update Strategy transformation eliminates the need for running two mappings to accomplish what could be a single task. The new mapping will accomplish both tasks. The completed mapping should look as follows:

Duration
This lab should take approximately 30 minutes.

10 - 2

PowerCenter 9.x Level I Developer Lab Guide

Lab 10. Data-Driven Operations

Exercises
Exercise 1: Create the Mapping
Step 1. Copy a mapping. Make a copy of the mapping and name it m_ODS_CUSTOMER_ACTIVE_upd_xx.
m_ODS_CUSTOMER_ACTIVE_xx

Save the repository.

Step 2. Create an update strategy transformation.


Use an Update Strategy transformation when keeping history information in a table or updating a table to keep the most current information.

Open the m_ODS_CUSTOMER_ACTIVE_upd_xx mapping. Delete the links between lkp_CUSTOMER and
ODS_CUSTOMER_ACTIVE.

Create an Update Strategy transformation and name it upd_ODS_CUSTOMER_ACTIVE. Copy/link the following ports from lkp_CUSTOMER to upd_ODS_CUSTOMER_ACTIVE:
CUST_ID CUST_NAME FIRST_CONTACT CUSTOMER_STATE CUSTOMER_ZIP CUSTOMER_TYPE DISCOUNT_RATE

Edit upd_ODS_CUSTOMER_ACTIVE.

Click on the Properties tab and add the following expression in the Update Strategy Expression field: IIF(UPPER(RTRIM(CUSTOMER_TYPE))='INACT IVE' or ISNULL(CUSTOMER_TYPE), DD_DELETE, DD_INSERT)

PowerCenter 9.x Level I Developer Lab Guide

10 - 3

Lab 10. Data-Driven Operations

Validate the formula and click the OK button to close the Expression Editor window. Click OK to close the Edit Transformation window. Save your work.

Step 3. Link the target definition. by name upd_ODS_CUSTOMER_ACTIVE to ODS_CUSTOMER_ACTIVE.


Autolink

Save the repository.

10 - 4

PowerCenter 9.x Level I Developer Lab Guide

Lab 10. Data-Driven Operations

Exercise 2: Create and Run the Workflow


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

On the Properties tab, set Treat source rows as to Data Driven. Select the Mapping tab. In the Navigation box, select the source SQ_INVOICE. Under Connections, click on the down arrow native_source and click OK. , select

In the Navigation box, select the target ODS_CUSTOMER_ACTIVE. Under Connections, click on the down arrow select native_target_xx and click OK. ,

You would not normally truncate the target on an update strategy session, but previous labs have distorted the target.

Under Properties, the Target load type should be defaulted to Normal. Scroll down to select the Truncate target table option. Link Start to

Click OK to close the Edit Tasks dialog box.

s_m_ODS_CUSTOMER_ACTIVE_upd_xx:

Save, validate and start

wf_ODS_CUSTOMER_ACTIVE_upd_xx.

Monitor and review the results for in the Workflow Monitor.


s_m_ODS_CUSTOMER_ACTIVE_upd_xx

PowerCenter 9.x Level I Developer Lab Guide

10 - 5

Lab 10. Data-Driven Operations

Step 2. Verify results session properties.

The 136 errors are duplicate rows that are rejected by the database. In the extra credit exercise, there will be a solution to omit these rows.

Step 3. Verify results session transformation statistics.


The difference between the applied rows and the affected rows is due to the fact that some of the rows were flagged for deletion. But since those rows did not already exist in the target, no corresponding target rows were actually affected by these. The purpose of marking the rows for deletion instead of simply filtering them out is to solve the more general problem what if a customer record that was previously loaded had its status changed from ACTIVE to INACTIVE?

Step 4. Verify results preview data.

10 - 6

PowerCenter 9.x Level I Developer Lab Guide

Lab 10. Data-Driven Operations

Exercise 3: Extra Credit


The following exercise eliminates the database unique constraint violations. Consider there are 200 invoices and 30 customers. The objective was to identify active customers. With the INVOICE table as the source and the CUSTOMER table as the lookup, there may be several invoices per customer. Based on the criteria, it only takes one invoice to pass through the lookup. Since several are passing through, the database rejects them as unique constraint violations. In this exercise, you will add a sorter transformation. Using the DISTINCT property, you will eliminate the duplicate customers. The completed mapping should look as follows:

Step 1. Insert a sorter transformation. In the same mapping,


m_ODS_CUSTOMER_ACTIVE_upd_xx,

delete the link from fil_ODS_CUSTOMER_ACTIVE to lkp_CUSTOMER. Insert a sorter called srt_ODS_CUSTOMER_ACTIVE between fil_ODS_CUSTOMER_ACTIVE and lkp_CUSTOMER. Copy/link the CUST_NO port from fil_ODS_CUSTOMER_ACTIVE to srt_ODS_CUSTOMER_ACTIVE. Link the CUST_NO port from to the CUST_NO port in lkp_CUSTOMER.
srt_ODS_CUSTOMER_ACTIVE

Edit srt_ODS_CUSTOMER_ACTIVE: Under the Properties tab, turn on the Distinct property.

Save the mapping.

Start the wf_ODS_CUSTOMER_ACTIVE_upd_xx workflow again.

PowerCenter 9.x Level I Developer Lab Guide

10 - 7

Lab 10. Data-Driven Operations

Step 2. Verify results extra credit session properties.

Step 3. Verify results extra credit session transformation statistics.

10 - 8

PowerCenter 9.x Level I Developer Lab Guide

S-ar putea să vă placă și