Multiple source systems, need only one non null record

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
khushbu6
Participant
Posts: 3
Joined: Tue Mar 15, 2016 9:33 pm

Multiple source systems, need only one non null record

Post by khushbu6 »

Hi,

I have a scenario where I have records from multiple source systems like suppose there are 4 src system s1 s2 s3 s4.. I have policy number ,policy details ,name and general details from all the 4.

I need output where I have to get only one record for one policy number.I can have a requirement of first not null field then in that case , if there is null field in s1 and not null in s2, in that case it must be record from s2 that must go to output , I can have requirement to have last not null field, in that case if s4 is null, the record with s3 must go to output.

How to implement that?
Last edited by khushbu6 on Thu Feb 23, 2017 6:56 pm, edited 1 time in total.
Khushbu Malani
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard!

If all four sources are in the same database, effect a four way join and use COALESCE function in your SELECT query.

Otherwise (for example if you have heterogeneous data sources), effect the join in DataStage then use a downstream Transformer stage with a three-level If..Then..Else construct to implement your test.

Code: Select all

If Not(IsNull(s1.field)) Then s1.field Else If Not(IsNull(s2.field)) Then s2.field Else If Not(IsNull(s3.field)) Then s3.field Else s4.field
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
khushbu6
Participant
Posts: 3
Joined: Tue Mar 15, 2016 9:33 pm

Post by khushbu6 »

I tried but it wouldnt work as the field names are same .
There are basically imagine 4 data sets present, each with exactly same schema.so they have same fields namely policy number, policy location in all 4 datasets.Policy location may be null in 1st dataset and in that case I need to pick policy location from 2nd dataset.
Khushbu Malani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... you've said "dataset" now... does that mean this is actually a Parallel job?
-craig

"You can never have too many knives" -- Logan Nine Fingers
khushbu6
Participant
Posts: 3
Joined: Tue Mar 15, 2016 9:33 pm

Post by khushbu6 »

Really sorry.. Dont know how it selected server jobs.. it is yes paralled job..
Khushbu Malani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No worries, let me get you moved into the correct forum.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a Funnel stage to combine the four outputs, and a Transformer stage to loop through each group of four to transfer the first non-null record (use stage variables for each group to determine whether or not it has been output).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply