key generate

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
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

key generate

Post by shrey3a »

Hi,


I've a scenario as below

EMP id

123
123
456
456
222
234

I need to o/p in the format

emp id key

123 1
123 2
456 1
456 2
222 1
234 1

The logic is to start the seq again from 1 when ever the emp id changes.

Thanks in advance.....
Regards
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Search the forum for the numerous examples of using stage variables on sorted data to assign the ranking number. It's very easy, you'll need the data sorted in the desired order and then setup 3 stage variables to do the work.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Post by shrey3a »

Thanks ken...i found one...
Thanks Again


[quote="kcbland"]Search the forum for the numerous examples of using stage variables on sorted data to assign the ranking number. It's very easy, you'll need the data sorted in the desired order and then setup 3 stage variables to do the work.[/quote]
Luciana
Participant
Posts: 60
Joined: Fri Jun 10, 2005 7:22 am
Location: Brasil

Post by Luciana »

Use stage variables on sorted data.
Ex.: varEmp (@Null) := RowProcGetPreviousValue(ENTRADA.id)
varSeq (0) := if ENTRADA.id = varEmp then varSeq +1 else 1
--------------------------------------------------------
Target id_key := ENTRADA.id : varSeq
ashokyadav
Participant
Posts: 2
Joined: Wed Sep 14, 2005 6:13 pm

Stage Variable

Post by ashokyadav »

[quote="Luciana"]Use stage variables on sorted data.
Ex.: varEmp (@Null) := RowProcGetPreviousValue(ENTRADA.id)
varSeq (0) := if ENTRADA.id = varEmp then varSeq +1 else 1
--------------------------------------------------------
Target id_key := ENTRADA.id : varSeq[/quote]
-----------------------------------------------------------------------
I am new to the datastage , Where should this variable be defined? In job properties --> job control ?
Luciana
Participant
Posts: 60
Joined: Fri Jun 10, 2005 7:22 am
Location: Brasil

Post by Luciana »

Hi ashokyadav

No, this variable be defined in stage transformer.
Post Reply