Generate Unique No's

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

Generate Unique No's

Post by nima511 »

I have a target database with the below 2 fields. Field 1 has unique numbers.
E.g.
Field 1 Field 2
1 abc
2 def
3 ghi

I have a requirement wherin I need to insert records into this table.
I need to first look at the last number in field 1 and insert records starting from 4 onwards.

How do I achieve this?
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Extract maximum Field1 from the table to a file.

Read maximum field1 from the input file and use it in below expression in your insert job to generate unique number

Code: Select all

(@NUMPARTITIONS * ( @INROWNUM - 1)) +  @PARTITIONNUM + Max_Field1
You are the creator of your destiny - Swami Vivekananda
nima511
Participant
Posts: 22
Joined: Thu Oct 08, 2009 8:01 am

Post by nima511 »

Anbu,

Thank you very much for your help. It worked fine.
Post Reply