How to add sequence number

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
srao
Premium Member
Premium Member
Posts: 41
Joined: Mon Mar 19, 2007 12:42 pm

How to add sequence number

Post by srao »

how to add sequence number for Existing primary key field for uniqueness
for Example :

181DAC246 + start with the sequence 0001 to every record

181DAC246 +0001
181DAC247 +0002
thank you
Last edited by srao on Wed Apr 18, 2007 7:49 pm, edited 1 time in total.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Look into surrogate key generator. Search the forums. It has been discussed before.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You mean concatenate, not add - yes? If so, generate the number and use the colon (:) concatenation operator to stick them together. Perhaps you need a surrogate key generated, perhaps it just needs to be the @INROWNUM. You'd have to tell us.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is the base number hexadecimal and you wish to add, or is it the leading digits to which you want to append a four digit sequence number? Should the sequence number be hexadecimal or decimal?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Have a look at the FAQ forum on generating a unique counter in a parallel job. The surrogate key stage wont let you do a complex increment, a parallel transformer will. You need to use the parallel macros for partition numbers to make sure numbers are unique between parallel instances of the transformer.
srao
Premium Member
Premium Member
Posts: 41
Joined: Mon Mar 19, 2007 12:42 pm

Post by srao »

yes, it is concatenate in Datastage 7.x server job. @inrownum giving the variable length number 1,2,...10,....100 etc. I need a fixed 4 digit length like 0001...0010,..0100,..etc.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Code: Select all

PrimaryKey : FMT(@INROWNUM,"4'0'R")
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

FirstPart : Fmt(@INROWNUM, "R%4")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply