Key Management Concurrent Value - is not working correctly

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
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Key Management Concurrent Value - is not working correctly

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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>>';
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post 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...?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
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