Change Previous record

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rcil
Charter Member
Charter Member
Posts: 70
Joined: Sat Jun 05, 2004 1:37 am

Change Previous record

Post by rcil »

Hello All,

How is it possible to make the previous record zero.

Code: Select all

Col1	Col2    Min_Date	Max_Date	Code	COunt
123 	456 	2004-01-01 	2004-12-10 	30 	1
123 	456 	2004-12-11 	2004-12-10 	30 	1
If current.col1 = prev.col1 and current.col2 = prev.col2 and min_date = max_date + 1 and code = 30 then make previous record 0.

Result :

Code: Select all

Col1	Col2    Min_Date	Max_Date	Code	COunt
123 	456 	2004-01-01 	2004-12-10 	30 	0
123 	456 	2004-12-11 	2004-12-10 	30 	1
Thanks
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Do a reverse sort on the required keys and perform the logic using stage variables.
rcil
Charter Member
Charter Member
Posts: 70
Joined: Sat Jun 05, 2004 1:37 am

Post by rcil »

Sainath.Srinivasan wrote:Do a reverse sort on the required keys and perform the logic using stage variables.
I am trying to load everything into a Hash File. What kind of sort do I have to perform? and can you please explain how to perform the task with stage variables.

thanks
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Sort on col1 asc, col2 asc, Min_Date desc, Max_Date desc.

Store col1, col2, Min_Date and Max_Date in corresponding stage variables to compare with next set.

You can then do
If prevMin_Date = link.Max_Date + 1 And (same keys and 30)
link.1_or_0 = 0
Else
link.1_or_0 = link.1_or_0
End
Post Reply