RowProcGetPreviousValue and RowProcCompareWithPreviousValue

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
Sant
Participant
Posts: 15
Joined: Thu May 12, 2005 12:08 am

RowProcGetPreviousValue and RowProcCompareWithPreviousValue

Post by Sant »

Hi everybody


I have in a table differents field and ID_GROUPE_LOT, ID_DATE_DEBUT_VALIDITE (Julien format).
ID_DATE_FIN_VALIDITE (Julien format) = -1

I want to update ID_DATE_FIN_VALIDITE (Julien format) with the previous value of ID_DATE_DEBUT_VALIDITE - 1 day if it's the same ID_GROUPE_LOT. The bigger value of ID_DATE_DEBUT_VALIDITE must not be update
For that, I have a select with ID_GROUPE_LOT order ASC, ID_DATE_DEBUT_VALIDITE order DESC.

In my transformer, I use that :

If RowProcCompareWithPreviousValue ( L_LectODS_SUIVI_ETAT_LOCATIF.ID_GROUPE_LOT) Then RowProcGetPreviousValue( L_LectODS_SUIVI_ETAT_LOCATIF.ID_DATE_DEBUT_VALIDITE)-1 Else -1

But the value returned is ID_GROUPE_LOT - 1 .

Explain me how do that ?
Thaks for your help

Frederic from Paris in France
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
In general the routines mentioned for attaining/comparing the current and previous valuse use the basic's common space to save the last row's value and compare it with the current row's value.

The only thing the compare routine does is return @TRUE (or 1) if the value you have is the same you had in the previous one otherwise @FALS (or 0) is returned.

So you simply used an improper routine for what you need to perform.

How many values you can get of the date?
are there only 2 values?
If more then 2 values do you need a specific one?

all this will effect the solution you need!

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Sant
Participant
Posts: 15
Joined: Thu May 12, 2005 12:08 am

Post by Sant »

Like I explain, I must put the previous value ID_DATE_DEBUT_VALIDITE - 1 day for the same ID_GROUPE_LOT in ID_DATE_FIN_VALIDITE for give that :

id_groupe_lot........id_date_debut_validite........id_date_debut_validite
---------------........--------------------------........--------------------------
9.........................2453250.............................-1
9.........................2452154.............................2453249
9.........................2450669.............................2452153
12.......................2453158.............................-1
12.......................2451088.............................2453157
17.......................2453038.............................-1
17.......................2453020.............................2453037
18.......................2452349.............................-1
18.......................2451657.............................2452348
18.......................2449839.............................2451656
...

So I have many values of date.
Have you a idea. I'm a datstage basic user.

Thank you for your help

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

Post by Sainath.Srinivasan »

Maybe if you want to retain the max value, then your logic must be changed to

Code: Select all

If 
    RowProcCompareWithPreviousValue ( L_LectODS_SUIVI_ETAT_LOCATIF.ID_GROUPE_LOT) Then 
 RowProcGetPreviousValue( L_LectODS_SUIVI_ETAT_LOCATIF.ID_DATE_DEBUT_VALIDITE)-1 
Else 
  L_LectODS_SUIVI_ETAT_LOCATIF.ID_DATE_DEBUT_VALIDITE 
[/i]
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

If you want to perform this in 2 jobs, this is my suggesstion.

First job, based on the key do an update with date -1 and second job do an insert with the current values. While doing update, you should update the latest (previous value than current). I have no idea how you are maintaining this in your project.

HTWH.

Regards
Saravanan
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
Your example sugests the data is sorted in ascending order so in this case
You can manage the functionality using stage variables.
since they are computed sequentially use the last stage variable to hold the current value, this way when you compute stage variables that apear before the last one you can access it's value hence get the previous rows value.



IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Sant
Participant
Posts: 15
Joined: Thu May 12, 2005 12:08 am

Post by Sant »

Hi everybody

We cannot use 2 different RowProcPreviousValue inb the same. The only solution is to make that with 2 jobs. So I found a solution.

The first job update the ID_DATE_FIN_VALIDITE by the previous ID_DATE_DEBUT_VALIDITE

The second job update ID_DATE_FIN_VALIDITE = -1 if the previous ID_GROUPE_LOT is different.

This method match.

Thank you all for your help.
Post Reply