duplicates in outrownum

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
dnat
Participant
Posts: 200
Joined: Thu Sep 06, 2007 2:06 am

duplicates in outrownum

Post by dnat »

Hi,

We are doing a table refresh i.e we are loading the data from a sequential file to table. I have an id column in the table which should be unique. I am passing outrownum as the value for that. But the job is aborting with unique constraint violation. how is this possible.

i changed the job to take the id from the routine KeyMgtGetNextValue('n') and it is not giving any violation.

but i dont want to use this routine because i want the id to start from 1 everytime i load

can anyone help me with this
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The target table already has rows in it. @OUTROWNUM always starts from 1. You need to determine the current maximum key value before your job processes any rows, perhaps loading it into a hashed file with a constant key, and add this value to @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.
dnat
Participant
Posts: 200
Joined: Thu Sep 06, 2007 2:06 am

Post by dnat »

we are truncating the records in the table and then only loading it.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

@OUTROWNUM can never violate a unique constraint on a truncated table. Check for any other unique constraints that there may be. Check too that you are loading the column that you think you are with this sequence of integers - that is, verify that the design is doing what it is supposed to be doing. Look carefully at the error message; it should name the constraint, and you can then track it down in a more targeted fashion.
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