Page 1 of 1

RowProcGetPreviousValue and RowProcCompareWithPreviousValue

Posted: Tue Jun 28, 2005 1:37 am
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

Posted: Tue Jun 28, 2005 2:44 am
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,

Posted: Tue Jun 28, 2005 2:55 am
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

Posted: Tue Jun 28, 2005 4:36 am
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]

Posted: Tue Jun 28, 2005 5:32 am
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

Posted: Tue Jun 28, 2005 5:35 am
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,

Posted: Tue Jun 28, 2005 5:50 am
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.