Page 1 of 1
Key Management Concurrent Value - is not working correctly
Posted: Thu Oct 04, 2007 10:00 pm
by cosec
Hello ,
I am using the function KeyMgmtConcurrentNExtValue to derive a primary key.....it was wokring fine and now it has set it self to -1 and my job is hanging up.....what is the reason for this and how do i find out what the current value is
Posted: Thu Oct 04, 2007 11:28 pm
by ray.wurlod
What was the most recent prior good value? You may have experienced "arithmetic overflow".
To determine the current "next available key" value for a given sequence execute the following query.
Code: Select all
SELECT NAME, F1 FMT '10R' COL.HDG "Next Value" FROM SDKSequences USING DICT VOC WHERE NAME = '<<Sequence Name>>';
Posted: Fri Oct 05, 2007 12:05 am
by cosec
Hi Ray,
I managed to get the correct value...but when I run its still -1..I went through the code for this routine...and it seems when the file cannot be opened it returns -1. Prior to this execution the job aborted as one of the tables were locked......now all that is resolved but the ID which is generated is stuck at -1.
Should I have the administrator restart the datastage server ? will this resolve the problem...?
Posted: Fri Oct 05, 2007 12:38 am
by ArndW
What did Ray's suggestion return? If the file is corrupt it would give you an error message. If the file is broken then restarting DataStage won't do a thing.
Posted: Fri Oct 05, 2007 12:52 am
by cosec
Rays suggestion resulted in the correct sequence number......
but when I run it it's given me -1 as the ID
how can i overcome this issue...please advice
Posted: Fri Oct 05, 2007 2:37 am
by ray.wurlod
Make a copy of the routine, and add more complete error handling to the Open and ReadU statements.
Code: Select all
Common /Sequences/ Initialized, NextVal, SeqFile
EQUATE RoutineName TO 'KeyMgtGetNextValueConcurrent'
If NOT(Initialized) Then
* Not initialised. Attempt to open the file.
Initialized = 1
Open "SDKSequences" TO SeqFile
On Error
Call DSLogFatal("Error (code " : Status() : ") opening SDKSequences file.", RoutineName)
End
Else
* Open failed. Create the sequence file.
EXECUTE "CREATE.FILE SDKSequences 2 1 1"
Open "SDKSequences" TO SeqFile
On Error
Call DSLogFatal("Error (code " : Status() : ") opening SDKSequences file.", RoutineName)
End
Else
Ans = -1
Call DSLogWarn("Unable to open SDKSequences. Code " : Status(), RoutineName)
End
End
* Read the named record from the file.
* This obtains the lock (waiting if necessary).
Readu NextVal From SeqFile, Arg1
On Error
Call DSLogFatal("Error reading sequence " : Quote(Arg1) : ", code = " : Status(), RoutineName)
End
Else
NextVal = 1
End
Ans = NextVal
NextVal = NextVal + 1
* Increment the sequence value, and write back to file.
* This releases the lock.
Write NextVal On SeqFile, Arg1 Else Ans = -1
Use the new routine to diagnose what's happening.