Creating a unique field for data and use of @INROWNUM

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
PilotBaha
Premium Member
Premium Member
Posts: 202
Joined: Mon Jan 12, 2004 8:05 pm

Creating a unique field for data and use of @INROWNUM

Post by PilotBaha »

I know this "how do i create a unique number for the data that doesn't have a good key candidate?" issue has been beaten to death. In searches I did and talking to other folks I haven't seen much use of @INROWNUM. What is the best practice or what are the pros and cons of using this to create that unique field?

Thanks..
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: Creating a unique field for data and use of @INROWNUM

Post by ogmios »

@INROWNUM starts at 1 with every new run. You would already add it to another number to get something unique.

If you're using a database I would suggest that to generate unique keys.

Ogmios
In theory there's no difference between theory and practice. In practice there is.
PilotBaha
Premium Member
Premium Member
Posts: 202
Joined: Mon Jan 12, 2004 8:05 pm

Post by PilotBaha »

I left out an important point : in this case the table is being recreated.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Then @INROWNUM is a good choice, because it is guaranteed to be unique.

If you have a constraint on the output link, all this means is that you will have gaps in your sequence. If all you're after is uniqueness this is not a problem.

If you don't want gaps in the sequence, prefer @OUTROWNUM.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

PilotBaha wrote:I left out an important point : in this case the table is being recreated.
Some databases have the option to turn off generation of autoincrement fields so that they can be loadad with pre-existing data.
Phil Hibbs | Capgemini
Technical Consultant
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

I've had a lot of success with @OUTROWNUM, even when appending a table where the last used number is passed in as a job parameter. People are moving to a shared counter design such as a hash file because there is an increasing use of parallel processing, either by multiple instance standard jobs or parallel jobs. Are you sure your job will never become a multiple instance job?
PilotBaha
Premium Member
Premium Member
Posts: 202
Joined: Mon Jan 12, 2004 8:05 pm

Post by PilotBaha »

I am sure 99% :lol: It's a job that creates data for a repository to be used by a Crystal Reports report. Since it's a process that recreates one table and there will be no other update or insert to it that makes me feel comfortable with it.
Post Reply