Page 1 of 1

need logic to achieve requirement

Posted: Fri May 17, 2013 7:59 am
by skp
Hi Below is my input:

id country
100 India
100 USA
100 UK
200 India
200 France
200 Japan
300 UK
300 USA

Requirement: Here id having 2 groups (100, 200)
If country column contains "India" then I need to reject entire group not a single record and capture into a file.

Output:
id country
300 UK
300 USA

Reject Records:
id Country
100 India
100 USA
100 UK
200 India
200 France
200 Japan

Please let me know how to achieve this.

Posted: Fri May 17, 2013 10:03 am
by chulett
Do an exact search here for "fork join" or perhaps "fork-join".

Posted: Fri May 17, 2013 10:06 am
by priyadarshikunal
It can be as simple as bifurcating the records with India in one link and others in another link. Join those two back together and filtering out the matched record to reject file and unmatched records to output file.

Posted: Fri May 17, 2013 1:37 pm
by priyadarshikunal
filter condition Country="India"

It will be better if you tell us what you tried and what is the error. Is ID and Country are in different column or same column?

Re: need logic to achieve requirement

Posted: Sat May 18, 2013 7:01 am
by Prince_Hyd
Hi


Do like this

SEQ----------TRN------------ Target 1
Target2
Target 3

1)in Transformer keep the logic in (constraint : Index(country,'India',1) for Target1 and in that constraint itself you will find otherwise checkbox tick it so that the record which wont match that condition will move to the Target2.

2)In Target3 keep logic in constraint as id = 300

hope this will slove your problem.

Posted: Sat May 18, 2013 9:25 am
by jwiles
In v8.5 or above of DataStage, you can accomplish this with a sort and a 2-pass loop in a parallel transformer. In any version, you can accomplish this with a transformer-sort-transformer combination.

v8.5+:
Partition/Sort on id
In the Transformer:
Loop Iteration 1: Determine if India is present in the group, set a flag to indicate yes or no
Loop Iteration 2: If Yes, send records to Reject link, if No, send records to main output link

Any version:
Transformer 1: Create a new integer column. If Country=India set the value to 1 otherwise set to 0
Sort: Partition on ID, sort on ID and new column (descending)
Transformer 2: Keep up with key changes. If first record in the key has the new column value = 1, send all records in that group to Reject, otherwise send them to the main output

Regards,