How to Achieve this Logic?

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

laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

How to Achieve this Logic?

Post by laknar »

Hi All,

I have two tables one is code and another is Customer.

Number Code CustID
123456 12 123
123456 22 234


CustID Address
123 laknar
234 standard

I have to write a logic if code starts with 1 the populate corresponding Address column based on CustID
strucked with the second logic
else if code starts with 2 then look back the address column which has come for code starts with 1 using CustID(i.e laknar).


Can anyone advice this logic .
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

You can use a stage variable to capture previous addresses, so you can have something like:

if CustID[1,1] = '1' then DSLink1.Address else StageVar1

simply populate your output column with StageVar1

This assumes data is sorted in the correct order of processing.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Hi,

i believe the stage variable will only hold current processing data and it will not go back to previous data.
loop will run when in sequential mode.
f CustID[1,1] = '1' then we have to go for CustID[1,1] = '2' address values.
if not correct please correct me.

or shall i have corresponding code 2 values lookup to link the address.
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

Dont worry about variables beginning with 2, the logic reads:

StageVar1 = if CustID[1,1] = '1' then DSLink1.Address else StageVar1

StageVar1 will be persistent so you can access previous values.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Hi,

.
if CustID[1,1] = '2' then Address
Else if CustID[1,1] = '1' then StageVar1
else setnull

for above logic what sort is required.

order by number,code desc

shall i enable the sort in the transformer stage.
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

It depends on your requirements. If you want to process the records in the order it comes, don't do sort. If you could explain with more example of codes, it would be better.

code cust
12 A
31 B
22 C
21 D

So what should be the ouput, if the input is like shown above..
Kandy
_________________
Try and Try again…You will succeed atlast!!
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Hi,

I want to sort some columns and order by descending.
number,code
and i want to keep the same sort in following stages.
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

if you want to sort on number and code (both DESC), then the stage variable logic which was discussed earlier will not work. Requirements should be clear so that people here can give their thoughts.
Kandy
_________________
Try and Try again…You will succeed atlast!!
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

I have two tables one is code and another is Customer.

Number Code CustID
123456 12 123
123456 22 234


CustID Address
123 laknar
234 standard

if code starts with 2 then corresponding address from customer table.
if code starts with 1 then address column of code[1,1]='2'.

this is my logic.please advice me.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

I have two tables one is code and another is Customer.

Number Code CustID
123456 12 123
123456 22 234


CustID Address
123 laknar
234 standard

if code starts with 2 then corresponding address from customer table.
if code starts with 1 then address column of code[1,1]='2'.

this is my logic.please advice me.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

I have two tables one is code and another is Customer.

Number Code CustID
123456 12 123
123456 22 234


CustID Address
123 laknar
234 standard

if code starts with 2 then corresponding address from customer table.
if code starts with 1 then address column of code[1,1]='2'.

this is my logic.please advice me.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You have been given a solution. Did you try it?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

hi ray,

I have tried.but im not getting the expected result.
bit of confusion with the sort.

db2stage------lookup-----TX------Dataset

sorting the code by descending.
how can i keep the same in next stages.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Hi,

can any one advice me regarding this
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

The sort order is maintained as long as you don't repartition or resort the data.

I suspect that you may not have managed your partitioning strategy correctly.

A simple test... use a single node configuration file... if your results are correct running on a single node, then you have a partitioning logic flaw. If your results remain incorrect, then you have a transformation logic flaw.

Mike
Post Reply