Help with the code

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
wittyme
Premium Member
Premium Member
Posts: 151
Joined: Tue Sep 15, 2009 2:03 pm
Location: Chicago

Help with the code

Post by wittyme »

There are like 1000 rows and I need a new column with simultaneous 100 and 200 and each row...

like the new column should be

100
200
100
200

How to get to this...
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Do you have any criteria for a row to have 100 or 200?
You are the creator of your destiny - Swami Vivekananda
wittyme
Premium Member
Premium Member
Posts: 151
Joined: Tue Sep 15, 2009 2:03 pm
Location: Chicago

Post by wittyme »

Not really... I am getting duplicate 100 and 200 values from my source. So, I want to add it in the job.

No criteria specifically.
chowdhury99
Participant
Posts: 43
Joined: Thu May 29, 2008 8:41 pm

Post by chowdhury99 »

It does not make sense to get same 2 columns. Anyway, you may map source column to both target column.

Thanks
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Completely random 100 and 200 values? Or duplicating a source row so that you have one with 100 and the other with 200? Other?

For former, a round robin partitioner and then base the new column on @PARTITIONNUM or stage variables (if 100 then 200 else 100 although that won't necessarily be balanced unless using single partition). For duplicating source rows, send through a copy stage with two outputs and then through a column generator on each link, one setting to 100, the other to 200. For other...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I think you mean "alternating" rather than "simultaneous".

If the Transformer stage is operating in Sequential mode, then all you need are two stage variables, one to remember the previous row and the other to toggle the value.

Once you get to parallel operation you have to answer more questions, such as does it matter whether the partitions are processed independently (which might mean that you end up with slightly more 100 values than 200 values particularly if each partition processes an odd number of rows).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Actually you could do it with one uint8 stage variable whose initial value is not 100.

Code: Select all

svValue  <--  If svValue <> 100 Then 100 Else 200
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

wittyme wrote:Not really... I am getting duplicate 100 and 200 values from my source. So, I want to add it in the job.

No criteria specifically.
What will happen in the following case ?
Key
Tom
Jerry
Jerry
Jerry
Tom
You will get
GenValue Key
100 Tom
200 Jerry
100 Jerry
200 Jerry
100 Tom
Is that what you want ?
wittyme
Premium Member
Premium Member
Posts: 151
Joined: Tue Sep 15, 2009 2:03 pm
Location: Chicago

Post by wittyme »

hmmm... yeah... similar case
Post Reply