datastage realtime senarios

Upload: arc

Post on 08-Jul-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 datastage Realtime Senarios

    1/23

    Que: source ...........>transformer.........>target

    In source i have only one record.

    I want 10 records(same record will repeat) in target.

    can any one tell me the logic in transformer

    Ans: using looping you ca do that to call looping you have to use @IT!ATI"#

    declare stgvar$col1

    in loop you hav to mention If @IT!ATI"#$1 then stgvar

    else if @IT!ATI"#$% then stgvar and so on till @IT!ATI"#$10

    and in output map stgvar to out col

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: my seq le 10 columns but in my target i want only 3

    coluoumns what we can do?

    Ans$ 1) only pass ' col in transformer stage

    %use oracle we can do

    'use copy we can do

    *) +se ,odify -tage

    )+se /lter option of seuential /le stage and specify the cut(+#I)

    command.

    2: cut d 343 f1445

    (Assuming columns 14 4 5 are to 6e loaded)

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: scenario based

    Input

    id code

  • 8/19/2019 datastage Realtime Senarios

    2/23

    111 0140%40'

    %%% 0*40

    2pected output

    id code

    111 01

    111 0%

    111 0'

    %%% 0*

    %%% 0

    78I4 the code column here can have any num6er of delimited values. Its not/2ed.

    A!:  9e have to do olumn to !ow convertion i.e vertical to hori;ontal

    pivotting

    use pivot enterprise for this purpose

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: source has % /elds li

  • 8/19/2019 datastage Realtime Senarios

    3/23

    A# I 9I>> CT T "+T=+T >IB TI-....

    ompany loc count

     T- 8 '

    ?A#

    I?, 8 '

    ?A#

    > 8 '

    ?A#

    Ans: sourec aggregate (use group 6y and ta

  • 8/19/2019 datastage Realtime Senarios

    4/23

    1. looA!8

    10% "# 10' J000

    10' ,IB

    !esult will 6e

    I #A, -A>A!8

    10% "#

    10' ,IB J000

  • 8/19/2019 datastage Realtime Senarios

    5/23

    '. ,erge stage: ,erge -tage is a =rocessing -tage which is used to perform

    the hori;ontal com6ining. This is one of the stage to perform this operation

    lioo

  • 8/19/2019 datastage Realtime Senarios

    6/23

    started on eachO 6y for

  • 8/19/2019 datastage Realtime Senarios

    7/23

    Croup ids)

    in transformer chec# 

    create % stage var

    stg1$name

    stg%$ if IAT !TAI#$ >A-T

    drag column to output dataset

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

  • 8/19/2019 datastage Realtime Senarios

    8/23

    &&&&&&&&&&&&&&&

    Que: convert single column to multiple column

    source

    55555555555555555555555

    I ,o6ile

    1 samsung

    1 no

  • 8/19/2019 datastage Realtime Senarios

    9/23

    %. -e -ortTfm1!,tfm% out

    -ort and mar< ogic in Transformer1 :

    create stage var stg1

    -tg1$ if

  • 8/19/2019 datastage Realtime Senarios

    10/23

     

    ) In o6 -euences ommand Activity.

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&

    ue: Input 7ile

    ummy

    1

    "utput should 6e liooping

  • 8/19/2019 datastage Realtime Senarios

    11/23

    in looping : give condition @IT!ATI"#U$

    in Transformer ummy $ @IT!ATI"#

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: I have /le with empid4empname and I want to load these two /elds

    along with sal in my target

    1)salary must 6e same for all the records

    %)I want pass the salary at run time

    Ans: 

    1. reate Ho6 parameter salary so that you can pass same salary for all

    records runtime

    and map this column to output dataset with new column name

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&

    Que: ha8e two source tables9les numbered 1 and %.

    In the the target4 there are three output ta6lesE/les4 num6ered '4* and .

    to the output * the records which are common to 6oth 1 and % should go.

    (I##! "I#)

    to the output ' the records which are only in 1 6ut not in % should go

    (>7T "+T! "I#)

    to the output the records which are only in % 6ut not in 1 should go.

    (!ICT "+T! "I#)

     how to go with this scenario

    A!:

    u can use Hoin stage with all three option.

    1.) Inner Hoin

    %.) >eft outer Hoin

    '.) !ight outer Hoin

  • 8/19/2019 datastage Realtime Senarios

    12/23

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: my in$ut is li#e below

    empno sal

    ravi 1000

    raHu %000

    srinu '000

    rao 00

    i want oEp li

  • 8/19/2019 datastage Realtime Senarios

    13/23

    F=ad stringF function.

    %. 8ou can divide sal 6y 1000 and multiply 6y % and pass this stage output to

    iteration

    i.e @IT!ATI"# U$-tgvar1

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&

    Que: 6y in$ut is lli#e

    col1 col% col' col*

    #+>> a 6 c

    < #+>> l m

    "utput should 6e li>

    1 6 % < l m #+>>

    a c

    1 #+>>

  • 8/19/2019 datastage Realtime Senarios

    14/23

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&&&&&

    Que: Input:

    ummy

    a

    a

    a

    "Ep: ummy

    '

    Ans:  1. use aggregator stage (count function)

    %. 9ith d help of transformer (using stgvar)

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&

    Que: atastage !eal time scenario

    source ta6le name A A ? ? ? In source ta6le data li

  • 8/19/2019 datastage Realtime Senarios

    15/23

    and pass count to output column

    % nd is using stage varia6les and without loop varia6les.

    !tg1 ame

    +ount1

    -tgQ%$ if -tgQ1$Temp then ountV1 else count

    )em$ !tg1

    in the transformer stage output lin< u can create one more column that

    seuence no in that column derivation call -tgQ%

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&

    Que: have source like this

    a,b,c,1,2,3 ( All this in one column

    reuired output: W(a464c41)4(a464c4%)4(a464c4')X

    Ans: 

    1. -ourceT!!=ivotTarget46y using these order of stages we can get

    reuired output.

     Transformer:

    we have to concatenate the values 6y using loop(we will get li

  • 8/19/2019 datastage Realtime Senarios

    16/23

  • 8/19/2019 datastage Realtime Senarios

    17/23

    In transformer stage we have to concatenate the input columns

    li

  • 8/19/2019 datastage Realtime Senarios

    18/23

    num6er and the last nonnull values for the rest of the columns.

    my desired result is

    I -e ' *

    1000 15 " 8 JJJ

    1001 10 A 8

    ans: seq555>tfm5555> ;6555>out

    -tage varia6les will help here. -ort the data on I and -e.

    sv>ast' $ I7 (In.I$sv>astI) T# #ullToQalue(In.'4sv>ast') >-

    #ullToQalue(In.'4FF)

    sv>ast* $ I7 (In.I$sv>astI) T# #ullToQalue(In.*4sv>ast*) >-

    #ullToQalue(In.*4FF)

    -Q>ast

    etc.

    sv>astI $ In.I

    =ass all rows out of the transform stage. Add a removeduplicates

    stage and

  • 8/19/2019 datastage Realtime Senarios

    19/23

    !+# "B

    test[se

    9A!#I#C

    test[se1

    7AI>

    testse%

    ,ut$ut :

     o6status o6name

    !+# "B test[se

    9A!#I#C test[se1

    7AI> test[se'

    9e are using datastage server Ho6s.(J.v) on 9indows server.

    Ans: -olutions we had tried :

    9e had splitted the single source lin< into two lin

  • 8/19/2019 datastage Realtime Senarios

    20/23

  • 8/19/2019 datastage Realtime Senarios

    21/23

    Question :souce le ha8ing the columns li#e

    ame +om$any

    out

    stgvar1$ if company $3I?,3 then countV1 else stgvar1

    stgvar1$0

    stgvar%$ if company $3T-3 then count%V1 else stgvar%

    stgvar%$0

    stgvar'$ if company $39I=!"3 then count'V1 else stgvar'

    stgvar'$0

    in column derivation if company$i6m then stgvar1 elseif company$tcs then

    stgvar% else if company$wipro then stgvar' else 0

     %. seq555>sort55>tfm55>out 

    /rst sort the 6oth name and compamy and then4 using stage varia6le in

    transformer:

  • 8/19/2019 datastage Realtime Senarios

    22/23

    curr$ name:company

    val$if curr U prev then 1 else valV1

    prev$curr

    o.p $ val

    name4company4val

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&

    Q2e: scenario is li

  • 8/19/2019 datastage Realtime Senarios

    23/23

    target%

    %4'000

    14%'00

    41100 with out using transformer

    Ans:

    1. tgt1[[[[ 

      G

    sourcetransformer

      G[[[[[tgt%

    in transformer

     TCT1

      constraint mod(deptno4%) $ 1

      source.deptno deptno

      source.sal sal

     TCT%

      constraint mod(deptno4%) $ 0

      derivation

      source.deptno deptno

      source.sal sal

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&