Logic for finding sequence Gap

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
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Logic for finding sequence Gap

Post by opdas »

Hi,
I have this situation where I need to find the gaps in the sequence and write all the gap in a file.


Source is like

Code: Select all

Col1     Col2
A            1
A            3
A            4
B            2
B            5
B            7
The target would be:

Code: Select all

Col1      Col2
A            2
B            3
B            4
B            6
I have to take into account the Max and Min value in Col2 and find sequence gaps for each unique entry for Col1.

Any idea is appreciated.

Regards
Om
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Sort by Col1, Col2 use stage variables to find the gap in the sequence and write to the target.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yes, a group change dance is required that can be accomplished via stage variables. THis has been discussed here a lot. Make the search engine your best friend :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

How many records will be there in the gap?
If the number of record in the gap is less, say 1 or 2 or 3 it ok, else you need to have that many stage variable to hold the values to compare and give as output.
For that case, you can build you own custome stages or routien to have the looping funtion in it.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.
dwblore
Charter Member
Charter Member
Posts: 40
Joined: Tue Mar 28, 2006 12:02 am

Post by dwblore »

opdas wrote:How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.
Life of the stage variable is the stage itself ie it lives until the entire recordset is processed.

Have Two Stg Varaibles
Old
New

Where Old=New
and New is populated with the desired column
mani_dwbi
Participant
Posts: 1
Joined: Thu Jun 01, 2006 7:55 am

LTRA_HLP

Post by mani_dwbi »

[quote="opdas"]How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.[/quote]

Hello OPD,
The best link what i think tht, please look into Duplicate CDR check JOb(for intec).
Technical Analyst
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

As mentioned have two stage variable.

Initial declaration
Old = ''
New = ''

Stage variable derivation
Old = New
New = Input Column.


If Old = New Then {logic for duplicate} else {logic for new}
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
opdas
Participant
Posts: 115
Joined: Wed Feb 01, 2006 7:25 am

Post by opdas »

Kumar:
Thanks a lot , its working now, I should have got this before :shock:

Mani:
Thanks for the reply...... I'll definetly search your Intec Jobs :wink:
Post Reply