You are on page 1of 10

Lab 8

Basic Lookup

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.........................8
Reference: Connected Vs Unconnected Lookups ..... 10

PowerCenter 9.x Level I Developer Lab Guide

8-1

Lab 8. Basic Lookup

Lab at a Glance
The exercises in this lab are designed to walk the student
through the process of using a Lookup transformation.

Objectives
After completing the lab, the student will be able to use a
Lookup transformation.

Summary
The purpose of this lab is to load an ODS table with records for
only those customers who have one or more completed, noncancelled, invoices on record.
The data will be extracted from the INVOICE table. The
CUSTOMER table will be used as the lookup table. The data
will be loaded into a target table called
ODS_CUSTOMER_ACTIVE.
SOURCE: INVOICE
TARGET: ODS_CUSTOMER_ACTIVE
The completed mapping should look as follows:

Duration
This lab should take approximately 40 minutes.

8- 2

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Basic Lookup

Exercises
Exercise 1: Create the Mapping
Step 1. Import the source table.
Clear the Source Analyzer workspace (right-click
anywhere in the workspace and select Clear A ll).
Continue to work in the assigned student folder and
import the INVOICE relational source table from the SDBU
database schema.
The source should look as follows:

Step 2. Import the target.


Clear the Warehouse Designer workspace (right-click
anywhere in the workspace and select Clear A ll).
Import the ODS_CUSTOMER_A CTIVE relational database
target table from the TDBUxx database schema.
The target should look as follows:

Save the repository.

PowerCenter 9.x Level I Developer Lab Guide

8-3

Lab 8. Basic Lookup

Step 3. Creating a mapping.


Create a mapping called
m_ODS_CUSTOMER_ACTIVE_xx.
Step 4. Add source and target.
Add the INVOICE source definition with its respective
Source Qualifier to the mapping:

Add the target definition ODS_CUSTOMER_A CTIVE.


Save the repository.
Step 5. Create a filter transformation.
Create a Filter transformation
named
fil_ODS_CUSTOMER_ACTIVE.
Link the following ports from sq_INVOICE to
fil_ODS_CUSTOMER_A CTIVE : CUST_NO , DA TE_CLOSED and
CA NCELED .
Add the following filter condition to
fil_ODS_CUSTOMER_A CTIVE (on the Properties tab):
The only inv oices that w ill meet this filter
condition contain a date in the
DATE_CLOSED column and w ere not
canceled.

NOT (ISNULL (DATE_CLOSED)) AND


CANCELED = 0
The mapping should look as follows:

Save the repository.


Step 6. Create a lookup transformation.
Click the Lookup Transformation
8- 4

button. Position the

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Basic Lookup

pointer in the workspace and click again.


The Select Lookup Table for Lookup Transformation dialog
appears.

Since the CUSTOMER table has not yet been analyzed or


imported as a source or a target, it must be imported now.
Click on the Import button.
Enter the login information needed to connect to the
odbc_source location:

Expand the SDBU schema and TA BLES node, and select the
CUSTOMER table:

Click OK and a Lookup transformation will appear in the


workspace.
Rename the Lookup transformation lkp_CUSTOMER.
Link CUST_NO from fil_ODS_CUSTOMER_A CTIVE to an
empty port in lkp_CUSTOMER.
PowerCenter 9.x Level I Developer Lab Guide

8-5

Lab 8. Basic Lookup

Double-click on the header of lkp_CUSTOMER.


The Edit Transformations dialog box appears.
Click on the Condition tab and click the
condition button:

The Designer w ill automatically choose the


ports to compare based on the sequential
order of Lookup ports and Input ports.

A dd a new

Select CUST_ID and CUST_NO for the condition.


Change the Connection Information on the Properties tab to
$Source :

Because the source and lookup tables


come from the same database (schema),
the $Source v ariable may be used.

Click OK to close the Edit Transformations dialog box.


Save the repository.

8- 6

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Basic Lookup

Step 7. Link the target definition.

the lkp_CUSTOMER to
ODS_CUSTOMER_A CTIVE :
A utolink by name

Iconize the mapping, which should look as follows:

Save the repository.

PowerCenter 9.x Level I Developer Lab Guide

8-7

Lab 8. Basic Lookup

Exercise 2: Create and Run the Workflow


Step 1. Create a workflow.
Create a workflow called
wf_ODS_CUSTOMER_ACTIVE_xx.
Create a session task called
s_m_ODS_CUSTOMER_ACTIVE_xx.
Double-click on the session task. The
box appears.

Edit Tasks

Select the Mapping tab.

In the Navigation box, select the source

dialog

SQ_INVOICE.

Under Connections, click on the down arrow


native_source and click OK.

, select

In the Navigation box, select the target


ODS_CUSTOMER_A CTIVE .

Under Connections, click on the down arrow


select native_target_xx and click OK.

Under Properties, the Target load type should be


defaulted to Normal. Scroll down to select the
Truncate target table option.

Click OK to close the Edit Tasks dialog box.

Link Start to s_m_ODS_CUSTOMER_A CTIVE_xx :

Save, validate and start wf_ODS_CUSTOMER_A CTIVE_xx .


Monitor and review the results for
s_m_ODS_CUSTOMER_A CTIVE_xx in the Workflow
Monitor.

8- 8

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Basic Lookup

Step 2. Verify results session properties.


Though not an ideal production solution,
this lab should produce unique constraint
errors. After the 28 row s load, some of
the subsequent row s are try ing to insert a
row w ith the same key. This scenario w ill
be dealt w ith in later labs.

Step 3. Verify results session transformation


statistics.

Step 4. Verify results preview data.


Note that only the first few row s are show n
here.

PowerCenter 9.x Level I Developer Lab Guide

8-9

Lab 8. Basic Lookup

Reference: Connected Vs Unconnected


Lookups
Like a number of other transformations, Lookups can be
configured to be connected or unconnected:

8- 10

PowerCenter 9.x Level I Developer Lab Guide

You might also like