Sunteți pe pagina 1din 17

Unit 13.

Unconnected Lookup,
Parameters and Variables

Unit 13

Unit Objectives
Understand why and how to use:
Unconnected Lookup transformation
System variables
Mapping parameters and variables

Use these features in a mapping

Unit 13

Unconnected Lookup

Commonly used when a lookup not needed for every record


No links from/to other transformations
Lookup data is called at the point in the mapping that needs it
Lookup function can be set within any transformation that supports
expressions
Unconnected Lookup

Function in the Expression


calls the Unconnected Lookup

Unit 13

Calling an Unconnected Lookup


Use Lookup function within a conditional statement
Condition

Row keys
(passed to Lookup)

IIF ( ISNULL(customer_id),:lkp.MYLOOKUP(order_no), customer_id)


Lookup function

Condition is evaluated for each row but Lookup function


is called only if condition is satisfied

Unit 13

Unconnected Lookup Advantages


Data lookup is performed only for those rows which
require it. Substantial performance can be gained
EXAMPLE: A Mapping will process 500,000 rows. For two
percent of those rows (10,000) the item_id value is NULL.
Item_ID can be derived from the SKU_NUMB.

IIF ( ISNULL(item_id), :lkp.MYLOOKUP (sku_numb), item_id)

Condition
(true for 2 percent of all
rows)

Lookup
(called only when condition is
true)

Net savings = 490,000 lookups


Unit 13

Unconnected Lookup Functionality


One lookup port value may be returned for each lookup

Must check a
Return port in the
Ports tab, or
expression that
calls lookup is
invalid.

Unit 13

Connected versus Unconnected Lookups


CONNECTED LOOKUP

UNCONNECTED LOOKUP

Part of the mapping data flow

Separate from the mapping data


flow

Returns multiple values (by


linking output ports to another
transformation)

Returns one value - by checking


the Return (R) port option for the
output port that provides the
return value

Executed for every record


passing through the
transformation

Only executed when the lookup


function is called

More visible, shows where the


lookup values are used

Less visible, as the lookup is


called from an expression within
another transformation

Default values are used

Default values are ignored


Unit 13

Joins versus Lookups

Unit 13

System Variables
SYSDATE

Provides current datetime on the


PowerCenter Server machine
Not a static value

SESSSTARTTIME

Returns the system date value on the


PowerCenter Server
Used with any function that accepts
transformation date/time datatypes
Not to be used in a SQL override
Has a constant value

$$$SessStartTime

Returns the system date value as a


string. Uses system clock on machine
hosting PowerCenter Server
Format of the string is database type
dependent
Used in SQL override
Has a constant value
Unit 13

Mapping Parameters and Variables


Represent declared values:
Variables can change in value during run-time
Parameters remain constant during run-time

Apply to all transformations within a mapping


Declared in Mappings menu
Format is $$VariableName or $$ParameterName

Set/initialized in a parameter file, specified for the session task


Provide increased development flexibility
Can be used in pre and post-SQL

Unit 13

10

Declaring Mapping Parameters and


Variables
Mappings Declare Parameters and Variables menu option

Set datatype
User-defined
($$name)

Set
aggregation
type
Set optional
initial value

Unit 13

11

Using Mapping Parameters and


Variables

Use parameters or variables in expression


Unit 13

12

Functions to Set Mapping Variables


SETMAXVARIABLE($$Variable,value)
SETMINVARIABLE($$Variable,value)
SETVARIABLE($$Variable,value)
SETCOUNTVARIABLE($$Variable)

Unit 13

13

Parameters & Variables Initialization


Priority
Parameters

Variables

1. Parameter file

1. Parameter file

2. Declared initial value 2. Repository value


3. Default value

3. Declared initial value


4. Default value

Unit 13

14

Unit 13 Lab
Load Sales Fact Table
Create a mapping using:
Source Qualifier for homogeneous join
Unconnected Lookup transformation
Aggregator transformation
Mapping parameters
Create/run a workflow for this mapping

Staging
Area

Data
Warehouse

STG_TRANSACTIONS
STG_PAYMENT
(tables)

FACT_SALES
(table)

Unit 13

15

Lab Review
What did we accomplish with this lab?
Questions?

Unit 13

16

Unit 13 Quiz
When would you use :
Unconnected Lookup transformation?
Mapping parameters and variables?

Unit 13

17

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