Saturday, December 8, 2012

Sending alternate record to target


How to send alternate record to target?
Or
Sending Odd numbered records to one target and even numbered records to another target.
Solution:

Step 1: Drag the source and connect to an expression transformation.
Step2: Add the next value of a sequence generator to expression transformation.


SCR TO SEQ MAPPING

Step 3: In expression transformation make two port, one is "odd" and another "even".
And Write the expression like below


EXPRESSION PROPERTY

Step 4: Connect a router transformation to expression.
Make two group in router.
And give condition Like below


RTR PROPERTY

Step 5: Then send the two group to different targets.
The entire mapping is as below


5 comments:

  1. Hi Kareem ,
    I have one scenario like below

     I have a source with 1000 records. I want load this 1000 records into 5 Targets . The data into d targets r

     T1 …… 1-50 and
     T2 …… 51-100 and
     T3 …… 101-150 and
     T4 …… 151-200 and
     T5 …… 201-250 and

    Again d series starts from

     T1 ….. 251-300 and
     T2 …… 301-350 and
     T3 …… 351-450 and
    ;;;;
    ;;;;;;
    And so on
    The next time the Source may contain 10000 or it may change, but
    the series should into 5 targets mentioned in above.

    Thanks if u send to my mail .

    ReplyDelete
    Replies
    1. Hi Manohar,
      If the source having 1000 records. then

      1. Drag all the ports from SQ to Router Transformation.

      2. Create sequence generator t/r and set the fallowing properties in t/R.

      Start value : 1
      Increment by : 1
      End value : 250
      Current value : 1

      Cycle option(check)
      3. Connect the NEXT VAL port from Seq gen to Router t/R.

      4.In router t/r set the conditions in user defined groups.
      1st group=Next val<=50
      2nd group=Next val > 50 and Next val<=100
      3rd group=Next val > 100 and Next val<=150
      4th group=Next val > 150 and Next val<=200
      5th group=Next val > 200 and Next val<=250
      5. Finally connect
      1st Group -----> 1st Target table.
      2nd Group -----> 2nd Target table.
      3rd Group -----> 3rd Target table.
      4th Group -----> 4th Target table.
      5th Group -----> 5th Target table.

      6.Save the mapping. Create session and workflow and Run Workflow.

      Thanks,
      Kareem

      Delete
  2. Hi Kareem, I have a scenario like follwing.
    Let's say I have 500 records source and source is flat file. I want populate the one date for 1st 40 records and next date for next 40 records.

    I mean 02/08/2016 should inserted for first 40 records and 03/08/2016 for next set of 40 records and third set of 40 with 04/08/2016 and so on. How can I achieve this

    ReplyDelete

Thank you :
- kareem