read the line before

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
samp
Participant
Posts: 25
Joined: Thu Nov 06, 2003 4:34 am

read the line before

Post by samp »

hi,

i would like to know if it's possible to replace a value by the value on the line before.
I think it is possible in a transformer but i'm not sure.

i explain .


i have this kind of file :

week value
1 25
2 0
3 56

and i want to replace the 0 by 25.

1 25
2 25
3 56

thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

DataStage will forget about the previous line; but you can store the value in a stage variable in a transform stage and use that value in the next line. This is very commonly used for many different type of applications.
samp
Participant
Posts: 25
Joined: Thu Nov 06, 2003 4:34 am

Post by samp »

ok, but the problem is a little bit hard.

i have one hash file that contain a date and a value associate to this date.
this value is different from 0.

ex:
date1 | val
-----------------------
01/01/04 | 25
08/01/04 | 26
29/01/04 | 32

the reference link contains all datas (values could be equal to 0).
ex :
date2 |val
-------------------
01/01/04 |25
08/01/04 |26
15/01/04 |0
22/01/04 |0
29/01/04 | 32

and i would like to have :
date2 |val
------------------
01/01/04 | 25
08/01/04 | 26
15/01/04 | 26
22/01/04 | 26
29/01/04 | 32

my problem is to link the date in the transformer.
i must use a stage variable to stock the value of the first example and my stage variable should keep the value until the date2<date1
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I am not sure that the previous row will hold what you are looking for - since hashed files come in no particular order. Can you not do 2 lookups and performthe IF 0 logic in the transform stage?
samp
Participant
Posts: 25
Joined: Thu Nov 06, 2003 4:34 am

Post by samp »

Can you not do 2 lookups and performthe IF 0 logic in the transform stage?"
which means ??

i always must replace the zero value by the last non-zero value ... it seems simple, but stage variable just keep in memory the value of the previous row ...
that's why i put in a hash file all my non-zero values...but it doesn't work, because my date is a key value..

perhaps that i should not use a hash file... [/quote]
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since the date is your key, lookup hash file 1 (will give you either a record not found or a value), and hash file 2 (will give you a value that might be zero) and then the derivation does a

Code: Select all

IF NOT(Hash1Lookup.NOTFOUND) THEN Hash1Lookup.VAL ELSE Hash2Lookup.Val
Post Reply