update strategy
DESCRIPTION
Informatica: update Strategy TransformationTRANSCRIPT
-
6/4/2015 UpdateStrategyTransformationinInformatica
1
UpdateStrategyTransformationinInformatica
Updatestrategytransformationisanactiveandconnectedtransformation.Updatestrategy transformationisusedtoinsert,update,anddeleterecordsinthetargettable.Itcanalso rejecttherecordswithoutreachingthetargettable.Whenyoudesignatargettable,youneed todecidewhatdatashouldbestoredinthetarget.
Whenyouwanttomaintainahistoryorsourceinthetargettable,thenforeverychangein thesourcerecordyouwanttoinsertanewrecordinthetargettable.Whenyouwantanexactcopyofsourcedatatobemaintainedinthetargettable,thenifthe sourcedatachangesyouhavetoupdatethecorrespondingrecordsinthetarget.
Thedesignofthetargettabledecideshowtohandlethechangestoexistingrows.Inthe informatica,youcansettheupdatestrategyattwodifferentlevels:
SessionLevel:Configuringatsessionlevelinstructstheintegrationserviceto eithertreatallrowsinthesameway(Insertorupdateordelete)oruseinstructions codedinthesessionmappingtoflagfordifferentdatabaseoperations.
MappingLevel:Useupdatestrategytransformationtoflagrowsforinert,update, deleteorreject.
FlaggingRowsinMappingwithUpdateStrategy:
Youhavetoflageachrowforinserting,updating,deletingorrejecting.Theconstantsand theirnumericequivalentsforeachdatabaseoperationarelistedbelow.
DD_INSERT:Numericvalueis0.UsedforflaggingtherowasInsert.DD_UPDATE:Numericvalueis1.UsedforflaggingtherowasUpdate.DD_DELETE:Numericvalueis2.UsedforflaggingtherowasDelete.DD_REJECT:Numericvalueis3.UsedforflaggingtherowasReject.
Theintegrationservicetreatsanyothernumericvalueasaninsert.
UpdateStrategyExpression:
Youhavetoflagrowsbyassigningtheconstantnumericvaluesusingtheupdatestrategy expression.Theupdatestrategyexpressionpropertyisavailableinthepropertiestabofthe updatestrategytransformation.
Eachrowistestedagainsttheconditionspecifiedintheupdatestrategyexpressionandaconstantvalueisassignedtoit.Asampleexpressionisshowbelow:
IIF(department_id=10,DD_UPDATE,DD_INSERT)
MostlyIIFandDECODEfunctionsareusedtotestforaconditioninupdatestrategy transformation.
UpdateStrategyandLookupTransformations:
Updatestrategytransformationisusedmostlywithlookuptransformation.Therowfromthe sourcequalifieriscomparedwithrowfromlookuptransformationtodeterminewhetheritis alreadyexistsoranewrecord.Basedonthiscomparison,therowisflaggedtoinsertor updateusingtheupdatestrategytransformation.
UpdateStrategyandAggregatorTransformations:
Ifyouplaceanupdatestrategybeforeanaggregatortransformation,thewaytheaggregator transformationperformsaggregatecalculationsdependsontheflaggingoftherow.For example,ifyouflagarowfordeleteandthenlaterusetherowtocalculatethesum,thenthe integrationservicesubtractsthevalueappearinginthisrow.Ifitsflaggedforinsert,thenthe
aggregatoraddsitsvaluetothesum.
ImportantNote:
Updatestrategyworksonlywhenwehaveaprimarykeyonthetargettable.Ifthereisno primarykeyavailableonthetargettable,thenyouhavetospecifya primarykeyinthetarget definitioninthemappingforupdatestrategytransformationtowork.