Sie sind auf Seite 1von 9

BANGALORE TECHNICAL TRAININGS Onlinetrainingsbglr@gmail.com +9 !

" #"$%#

Lab &
Parameters and Variables

Lab at a Glance................................................................$

PowerCenter 9.x Level I Developer Lab Guide

8-1

Lab 8. Parameters and Variables

Lab at a Glance
Create the table if it is not existing in TDBU schema:-

CREATE TABLE TDBU.MP M! E"AMPLE # EMP$% E$AME DEPT$% $UMBER& !ARC'AR(#())*& $UMBER&

T%TAL +AL $UMBER& MA" !AR M,$ !AR $UMBER& $UMBER&

C%U$T !AR $UMBER & +ET !AR DATE *Ma..ing .arameters an/ 0ariables re.resent 0al1es in ma..ings an/ ma..lets. 2hen 3e 1se a ma..ing .arameter or 0ariable in a ma..ing& first 3e /eclare the ma..ing .arameter or 0ariable for 1se in each ma..let or ma..ing. Then& 3e /efine a 0al1e for the ma..ing .arameter or 0ariable before 3e r1n the session. MAPPING PARAMETERS

A ma..ing .arameter re.resents a constant 0al1e that 3e can /efine before r1nning a session. A ma..ing .arameter retains the same 0al1e thro1gho1t the entire session.

Example: 2hen 3e 3ant to extract recor/s of a .artic1lar month /1ring ETL .rocess& 3e 3ill create a Ma..ing Parameter of /ata t4.e an/ 1se it in 51er4 to com.are it 3ith the timestam. fiel/ in +6L o0erri/e.

After 3e create a .arameter& it a..ears in the Ex.ression E/itor. 2e can then 1se the .arameter in an4 ex.ression in the ma..let or ma..ing. 2e can also 1se .arameters in a so1rce 51alifier filter& 1ser-/efine/ 7oin& or extract o0erri/e& an/ in the Ex.ression E/itor of re1sable transformations.

MAPPING VARIABLES

Unli8e ma..ing .arameters& ma..ing 0ariables are 0al1es that can change bet3een sessions. The ,ntegration +er0ice sa0es the latest 0al1e of a ma..ing 0ariable to the re.ositor4 at the en/ of each s1ccessf1l session.

8-

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Parameters and Variables

2e can o0erri/e a sa0e/ 0al1e 3ith the .arameter file. 2e can also clear all sa0e/ 0al1es for the session in the 2or8flo3 Manager.

2e might 1se a ma..ing 0ariable to .erform an incremental rea/ of the so1rce. 9or exam.le& 3e ha0e a so1rce table containing time stam.e/ transactions an/ 3e 3ant to e0al1ate the transactions on a /ail4 basis. ,nstea/ of man1all4 entering a session o0erri/e to filter so1rce /ata each time 3e r1n the session& 3e can create a ma..ing 0ariable& ::,ncl1/eDateTime. ,n the so1rce 51alifier& create a filter to rea/ onl4 ro3s 3hose transaction /ate e51als ::,ncl1/eDateTime& s1ch as: T,ME+TAMP ; ::,ncl1/eDateTime ,n the ma..ing& 1se a 0ariable f1nction to set the 0ariable 0al1e to increment one /a4 each time the session r1ns. ,f 3e set the initial 0al1e of ::,ncl1/eDateTime to <=>=())?& the first time the ,ntegration +er0ice r1ns the session& it rea/s onl4 ro3s /ate/ <=>=())?. D1ring the session& the ,ntegration +er0ice sets ::,ncl1/eDateTime to <=(=())?. ,t sa0es <=(=())? to the re.ositor4 at the en/ of the session. The next time it r1ns the session& it rea/s onl4 ro3s from A1g1st (& ())?. Used in following transformations

Ex.ression 9ilter Ro1ter U./ate +trateg4

Initial and !efa"lt Val"e 2hen 3e /eclare a ma..ing .arameter or 0ariable in a ma..ing or a ma..let& 3e can enter an initial 0al1e. 2hen the ,ntegration +er0ice nee/s an initial 0al1e& an/ 3e /i/ not /eclare an initial 0al1e for the .arameter or 0ariable& the ,ntegration +er0ice 1ses a /efa1lt 0al1e base/ on the /ata t4.e of the .arameter or 0ariable. Data -@Defa1lt !al1e $1meric -@) +tring -@Em.t4 +tring Date time -@>=>=> Varia#le Val"es +tart 0al1e an/ c1rrent 0al1e of a ma..ing 0ariable Start Val"e The start 0al1e is the 0al1e of the 0ariable at the start of the session. The ,ntegration +er0ice loo8s for the start 0al1e in the follo3ing or/er: >. (. A. ?. !al1e in .arameter file !al1e sa0e/ in the re.ositor4 ,nitial 0al1e Defa1lt 0al1e

$"rrent Val"e The c1rrent 0al1e is the 0al1e of the 0ariable as the session .rogresses. 2hen a session starts& the c1rrent 0al1e of a 0ariable is the same as the start 0al1e. The final c1rrent 0al1e for a 0ariable is

PowerCenter 9.x Level I Developer Lab Guide

8-!

Lab 8. Parameters and Variables

sa0e/ to the re.ositor4 at the en/ of a s1ccessf1l session. 2hen a session fails to com.lete& the ,ntegration +er0ice /oes not 1./ate the 0al1e of the 0ariable in the re.ositor4. Note ,f a 0ariable f1nction is not 1se/ to calc1late the c1rrent 0al1e of a ma..ing 0ariable& the start 0al1e of the 0ariable is sa0e/ to the re.ositor4. !ariable Data t4.e an/ Aggregation T4.e 2hen 3e /eclare a ma..ing 0ariable in a ma..ing& 3e nee/ to config1re the Data t4.e an/ aggregation t4.e for the 0ariable. The ,+ 1ses the aggregate t4.e of a Ma..ing 0ariable to /etermine the final c1rrent 0al1e of the ma..ing 0ariable. Aggregation t4.es are:

$o"nt ,nteger an/ small integer /ata t4.es are 0ali/ onl4. Max All transformation /ata t4.es exce.t binar4 /ata t4.e are 0ali/. Min All transformation /ata t4.es exce.t binar4 /ata t4.e are 0ali/.

Varia#le %"n&tions !ariable f1nctions /etermine ho3 the ,ntegration +er0ice calc1lates the c1rrent 0al1e of a ma..ing 0ariable in a .i.eline. SetMaxVaria#le +ets the 0ariable to the maxim1m 0al1e of a gro1. of 0al1es. ,t ignores ro3s mar8e/ for 1./ate& /elete& or re7ect. Aggregation t4.e set to Max. SetMinVaria#le +ets the 0ariable to the minim1m 0al1e of a gro1. of 0al1es. ,t ignores ro3s mar8e/ for 1./ate& /elete& or re7ect. Aggregation t4.e set to Min. Set$o"ntVaria#le ,ncrements the 0ariable 0al1e b4 one. ,t a//s one to the 0ariable 0al1e 3hen a ro3 is mar8e/ for insertion& an/ s1btracts one 3hen the ro3 is Mar8e/ for /eletion. ,t ignores ro3s mar8e/ for 1./ate or re7ect. Aggregation t4.e set to Co1nt. SetVaria#le +ets the 0ariable to the config1re/ 0al1e. At the en/ of a session& it com.ares the final c1rrent 0al1e of the 0ariable to the start 0al1e of the 0ariable. Base/ on the aggregate t4.e of the 0ariable& it sa0es a final 0al1e to the re.ositor4. $reating Mapping Parameters and Varia#les >. (. A. ?. B. C. %.en the fol/er 3here 3e 3ant to create .arameter or 0ariable. ,n the Ma..ing Designer& clic8 Ma..ings @ Parameters an/ !ariables. -or- ,n the Ma..let Designer& clic8 Ma..let @ Parameters an/ !ariables. Clic8 the a// b1tton. Enter name. Do not remo0e :: from name. +elect T4.e an/ Data t4.e. +elect Aggregation t4.e for ma..ing 0ariables. Di0e ,nitial !al1e. Clic8 o8.

Example: Use of Ma..ing of Ma..ing Parameters an/ !ariables

EMP 3ill be so1rce table. Create a target table MP M! E"AMPLE ha0ing col1mns: EMP$%& E$AME& DEPT$%& T%TAL +AL& MA" !AR& M,$ !AR& C%U$T !AR an/ +ET !AR. T%TAL +AL ; +ALE C%MM E ::B%$U+ #Bon1s is ma..ing .arameter that changes e0er4 month*

8- "

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Parameters and Variables

+ET !AR: 2e 3ill be a//e/ one month to the ',REDATE of e0er4 em.lo4ee. Create shortc1ts as necessar4.

$reating Mapping >. (. A. ?. B. C. G. <. H. %.en fol/er 3here 3e 3ant to create the ma..ing. Clic8 Tools -@ Ma..ing Designer. Clic8 Ma..ing-@ Create-@ Di0e name. Ex: m m. m0 exam.le Drag EMP an/ target table. Transformation -@ Create -@ +elect Ex.ression for list -@ Create F@ Done. Drag EMP$%& E$AME& ',REDATE& +AL& C%MM an/ DEPT$% to Ex.ression. Create Parameter ::Bon1s an/ Di0e initial 0al1e as ()). Create 0ariable ::0ar max of MA" aggregation t4.e an/ initial 0al1e >B)). Create 0ariable ::0ar min of M,$ aggregation t4.e an/ initial 0al1e >B)).

>). Create 0ariable ::0ar co1nt of C%U$T aggregation t4.e an/ initial 0al1e ). C%U$T is 0isible 3hen /atat4.e is ,$T or +MALL,$T. >>. Create 0ariable ::0ar set of MA" aggregation t4.e.

>(. Create B o1t.1t .orts o1t T%TAL +AL& o1t MA" !AR& o1t M,$ !AR&

PowerCenter 9.x Level I Developer Lab Guide

8-#

Lab 8. Parameters and Variables

o1t C%U$T !AR an/ o1t +ET !AR. >A. %.en ex.ression e/itor for T%TAL +AL. Do the same as 3e /i/ earlier for +ALE C%MM. To a// : :B%$U+ to it& select 0ariable tab an/ select the .arameter from ma..ing .arameter. +AL E C%MM E ::Bon1s >?. %.en Ex.ression e/itor for o1t max 0ar. >B. +elect the 0ariable f1nction +ETMA"!AR,ABLE from left si/e .ane. +elect ::0ar max from 0ariable tab an/ +AL from .orts tab as sho3n belo3.+ETMA"!AR,ABLE#: :0ar max&+AL*

>G. %.en Ex.ression e/itor for o1t min 0ar an/ 3rite the follo3ing ex.ression: +ETM,$!AR,ABLE#::0ar min&+AL*. !ali/ate the ex.ression. ><. %.en Ex.ression e/itor for o1t co1nt 0ar an/ 3rite the follo3ing ex.ression: +ETC%U$T!AR,ABLE#::0ar co1nt*. !ali/ate the ex.ression. >H. %.en Ex.ression e/itor for o1t set 0ar an/ 3rite the follo3ing ex.ression: +ET!AR,ABLE#::0ar set&ADD T% DATE#',REDATE&IMMI&>**. !ali/ate.

(). Clic8 %J. Ex.ression Transformation belo3:

(>. Lin8 all .orts from ex.ression to target an/ !ali/ate Ma..ing an/ +a0e it. ((. +ee ma..ing .ict1re on next .age.

8- $

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Parameters and Variables

PARAMETER %ILE

A .arameter file is a list of .arameters an/ associate/ 0al1es for a 3or8flo3& 3or8let& or session. Parameter files .ro0i/e flexibilit4 to change these 0ariables each time 3e r1n a 3or8flo3 or session. 2e can create m1lti.le .arameter files an/ change the file 3e 1se for a session or 3or8flo3. 2e can create a .arameter file 1sing a text e/itor s1ch as 2or/Pa/ or $ote.a/. Enter the .arameter file name an/ /irector4 in the 3or8flo3 or session .ro.erties.

A .arameter file contains the follo3ing t4.es of .arameters an/ 0ariables:

'or(flow )aria#le References 0al1es an/ recor/s information in a 3or8flo3. 'or(let )aria#le References 0al1es an/ recor/s information in a 3or8let. Use .re/efine/ 3or8let 0ariables in a .arent 3or8flo3& b1t 3e cannot 1se 3or8flo3 0ariables from the .arent 3or8flo3 in a 3or8let. Session parameter Defines a 0al1e that can change from session to session& s1ch as a /atabase connection or file name. Ma..ing .arameter an/ Ma..ing 0ariable

USING A PARAMETER %ILE Parameter files contain se0eral sections .rece/e/ b4 a hea/ing. The hea/ing i/entifies the ,ntegration +er0ice& ,ntegration +er0ice .rocess& 3or8flo3& 3or8let& or session to 3hich 3e 3ant to assign .arameters or 0ariables.

Ma8e session an/ 3or8flo3. Di0e connection information for so1rce an/ target table. R1n 3or8flo3 an/ see res1lt.

PowerCenter 9.x Level I Developer Lab Guide

8-%

Lab 8. Parameters and Variables

+am.le Parameter file:Sample Parameter %ile for *"r example ,n the .arameter file& fol/er an/ session names are case sensiti0e. Create a text file in note.a/ 3ith name Para 9ile.txt KPractice.+T:s m MP M! Exam.leL ::Bon1s;>))) ::0ar max;B)) ::0ar min;>()) ::0ar co1nt;) $*N%IGURING PARAMTER %ILE 2e can s.ecif4 the .arameter file name an/ /irector4 in the 3or8flo3 or session .ro.erties. To enter a .arameter file in the 3or8flo3 .ro.erties: >. %.en a 2or8flo3 in the 2or8flo3 Manager. (. Clic8 2or8flo3s @ E/it. A. Clic8 the Pro.erties tab. ?. Enter the .arameter /irector4 an/ name in the Parameter 9ilename fiel/. B. Clic8 %J. To enter a .arameter file in the session .ro.erties:

8- 8

PowerCenter 9.x Level I Developer Lab Guide

Lab 8. Parameters and Variables

>. %.en a session in the 2or8flo3 Manager. (. Clic8 the Pro.erties tab an/ o.en the Deneral %.tions settings. A. Enter the .arameter /irector4 an/ name in the Parameter 9ilename fiel/. ?. Exam.le: D:M9ilesMPara 9ile.txt or :PM+o1rce9ileDirMPara 9ile.txt B. Clic8 %J.

edw_call_sp_aspect_call_dtl_fact.prm.prm

PowerCenter 9.x Level I Developer Lab Guide

8-9

Das könnte Ihnen auch gefallen