KeyMgt Function

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
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

KeyMgt Function

Post by rsunny »

Hi All,

I am using one of the Datastage functions which is KeyMgtGetNextValue("abc") where abc is the table name in two jobs . when i run the 1st job its working fine , and then if i run the 2nd job , i am getting an error saying that 'unique constraint violated'. So can we use KeyMgtGetNextValue("abc") in two different jobs or should i need to change the 'abc' to 'def' in 2nd load. Can you please let me know what is the best way to generate a surrogate key value where i am loading Data from different Data in different jobs , so thats why i used KeyMgtGetNextValue("abc") in different jobs but still getting an error when i run the 2nd job after i am done with my 1st job.

Any help is really appreciated

Thanks in advance
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The argument supplied to this routine is the name of the sequence (a name internal to DataStage), not necessarily the name of a table. Looks like the second table already has the "next" key. You need to check for this, or initialize the sequence, or use independent sequences, or some combination thereof.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Is this "abc" sequence name used for the same target table in your two jobs or two different targets?
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes, "abc" is your sequence name in the Key Mgt routines as both Ray and I have pointed out to you. Now, it may match the name of the target table you are using the generated key for but that's hardly necessary. And if you have multiple jobs targeting the same table then they should all use a common sequence.

One consideration is concurrency, could the two jobs be loading the same table at the same time? That would change the routine you would need to use.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Hi,

Yes,The two jobs are loading the same table at same time. So can you tell me how should i change the routine . should i change from "abc" to some other value?

Thanks in advance
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The routine will change. Look into KeyMgtGetNextValueConcurrent()
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 »

Was hoping that was obvious. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Thanks every one .As of now its working fine with this KeyMgtGetNextValueConcurrent()
Post Reply