Sie sind auf Seite 1von 13

BANGALORE TECHNICAL TRAININGS Onlinetrainingsbglr@gmail.

com +917411642061

Lab
Dynamic 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............12

PowerCenter 9.x Level I Developer Lab Guide

8-1

Lab. Dynamic 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 Dynamic Lookup transformation.

Summary
The purpose of this lab is to load an ODS_EMPLOYEE table with records. The data will be extracted from the EMPLOYEE flat file. The target table ODS_EMPLOYEE table will be used as the lookup table. SOURCE: EMP TARGET: EMPLOYEE_TGT 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. Dynamic 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 All). Continue to work in the assigned student folder and import the EMP 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 All). Import the EMPLOYEE_TGT 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. Dynamic Lookup

Step 3. Creating a mapping. Create a mapping called m_EMP_TGT_DYNAMIC_LOOKUP. Step 4. Add source and target. Add the EMP source definition with its respective Source Qualifier to the mapping:

Add the target definition ODS_CUSTOMER_ACTIVE. Save the repository. Step 5. Create a lookup transformation. Click the Lookup Transformation button. Position the pointer in the workspace and click again. The Select Lookup Table for Lookup Transformation dialog appears.

Since the EMPLOYEE_TGT table which is imported as a target. Click OK and a Lookup transformation will appear in the workspace. Rename the Lookup transformation

8- 4

PowerCenter 9.x Level I Developer Lab Guide

Lab. Dynamic Lookup

lkp_EMPLOYEE_TGT.

Copy/link the following ports from Double-click on the header of lkp_EMPLOYEE_TGT.


EMP_NO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

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

Select EMPNO and IN_EMPNO for the condition. Change the Connection Information on the Properties tab to $Source:
The Designer will automatically choose the ports to compare based on the sequential order of Lookup ports and Input ports.

PowerCenter 9.x Level I Developer Lab Guide

8-5

Lab. Dynamic Lookup

Because the source and lookup tables come from the same database (schema), the $Source variable may be used.

Make sure that Dynamic Lookup Cache check box and Insert/Else update box is checked. Now NewLookupRow input row port is added to ports which is not editable.
0 = Integration Service does not update or insert the row in the cache. 1 = Integration Service inserts the row into the cache. 2 = Integration Service updates the row in the cache.

8- 6

PowerCenter 9.x Level I Developer Lab Guide

Lab. Dynamic Lookup

Must give associated expression.


While using a dynamic lookup cache, we must associate each lookup/output port with an input/output port or a sequence ID. The Integration Service uses the data in the associated port to insert or update rows in the lookup cache. The Designer associates the input/output ports with the lookup/output ports used in the lookup condition.

When we select Sequence-ID in the Associated Port column, the Integration Service generates a sequence ID for each row it inserts into the lookup cache.

Change the data type of EMP_PK to Integer.Sequence-Id will be added. Click OK to close the Edit Transformations dialog box. Save the repository.

PowerCenter 9.x Level I Developer Lab Guide

8-7

Lab. Dynamic Lookup

Step 6. Create the Router Transformation rtr_EMPLOYEE_TGT Copy/link the following ports from lkp_EMPLOYEE_TGT to the router and create tow new groups INSERT and UPDATE
NewLookupRow EMP_PK EMP_NO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

8- 8

PowerCenter 9.x Level I Developer Lab Guide

Lab. Dynamic Lookup

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

Create two Update Strategy transformation name it upd_EMP_TGT_INS and upd_EMP_TGT_UPD.

and

Copy/link the following ports from rtr_EMPLOYEE_TGT INSERT Group to upd_EMP_TGT_INS and Update group to upd_EMP_TGT_UPD :
EMP_PK EMP_NO

PowerCenter 9.x Level I Developer Lab Guide

8-9

Lab. Dynamic Lookup

ENAME

o o o o
COMM

JOB MGR HIREDATE SAL

DEPTNO

Edit upd_EMP_TGT_INS. Click on the Properties tab and add the following expression in the Update Strategy Expression field: DD_INSERT Validate the formula and click the OK button to close the Expression Editor window Edit upd_EMP_TGT_UPD Click on the Properties tab and add the following expression in the Update Strategy Expression field: DD_UPDATE 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 8. Drag the target twice into workspace. Rename the targets as EMPLOYEE_TGT_INSERT and EMPLOYEE_TGT_UPDATE.

8- 10

PowerCenter 9.x Level I Developer Lab Guide

Lab. Dynamic Lookup

Step 9. Link the target definition.

Link manually from upd_EMP_TGT_INS to EMPLOYEE_TGT_INSERT and upd_EMP_TGT_UPD to EMPLOYEE_TGT_UPDATE

Save the repository.

PowerCenter 9.x Level I Developer Lab Guide

8 - 11

Lab. Dynamic Lookup

Exercise 2: Create and Run the Workflow


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

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

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_EMP_TGT_DYNAMIC_LOOKUP:

Save, validate and start wf_ODS_CUSTOMER_ACTIVE_xx. Monitor and review the results for s_ m_EMP_TGT_DYNAMIC_LOOKUP in the Workflow Monitor. Step 2. Verify results session transformation statistics.

8- 12

PowerCenter 9.x Level I Developer Lab Guide

Lab. Dynamic Lookup

Step 4. Verify results.


Note that only the first few rows are shown here.

PowerCenter 9.x Level I Developer Lab Guide

8 - 13

Das könnte Ihnen auch gefallen