Update Sequence number as part of the job sequence
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 46
- Joined: Tue Aug 21, 2007 5:39 am
- Location: Bangalore, India
Update Sequence number as part of the job sequence
Hi,
Every load we need to update key management value so that it starts from 1. We know that we can update this value from command line from the DS Administrator. This is a manual step.
But here we want to automate the job sequence in such a way that before running the job sequence, the sequence number should be updated to 1. Meaning it has to be run as part of the job sequence.
Can anybody help me how to update from the job sequence?
Thanks.
Every load we need to update key management value so that it starts from 1. We know that we can update this value from command line from the DS Administrator. This is a manual step.
But here we want to automate the job sequence in such a way that before running the job sequence, the sequence number should be updated to 1. Meaning it has to be run as part of the job sequence.
Can anybody help me how to update from the job sequence?
Thanks.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Where's it stored? My choice would be to use the SDK key management routines, and to use an appropriate command to reset the named sequence in the SDKSequences hashed file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 46
- Joined: Tue Aug 21, 2007 5:39 am
- Location: Bangalore, India
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Change one of the SDK key management routines available under Routines and use this in your sequence.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
FUNCTION KeyMgtReset(Arg1,Arg2)
Input: Arg1 - Name of the sequence
Input: Arg2 - Value to be set
Description: If this routine is called for the first time in a new environment and if the named sequence (Arg1) does not exist, this routine will create a new one and set the initial value as Arg2. If named sequence (Arg1) exists a reset happens.
Code: Select all
* Declare shared memory storage.
Common /Sequences/ Initialized, NextVal, SeqFile
EQUATE RoutineName TO 'KeyMgtReset'
If NOT(Initialized) Then
Initialized = 1
Open "SDKSequences" TO SeqFile
Else EXECUTE "CREATE.FILE SDKSequences 2 1 1"
Open "SDKSequences" TO SeqFile
Else Ans = -1
End
Ans = 0
* Reset the sequence value, and write back to file.
NextVal = Arg2
Writeu NextVal On SeqFile, Arg1 Else Ans = -1
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's TERRIBLE code!! You need to own the update lock before a Write to a hashed file, to prevent lost updates. You merrily proceed with your (unprotected) write even if the file could not be opened.
Code: Select all
FUNCTION ResetSDKSequence(SequenceName, ResetValue)
* If SequenceName is not provided, routine returns.
* If SequenceName does not exist it is created.
* If ResetValue is not provided, 1 is used.
* Returns NULL if any problem, ResetValue if successful.
$INCLUDE UNIVERSE.INCLUDE FILEINFO.H
Equate RoutineName To "ResetSDKSequence"
COMMON /Sequences/Initialized, NextVal, SeqFile
Ans = @NULL
If UnAssigned(SequenceName) Or IsNull(SequenceName) Or Trim(SequenceName) <= " "
Then
Message = "Sequence name not given."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End
If UnAssigned(ResetValue) Or IsNull(ResetValue) Or Not(Num(ResetValue))
Then NewVal = 1
Else NewVal = ResetValue
* Open SDKSequences file if it is not already open.
If Not(FileInfo(SeqFile, FINFO$IS.FILEVAR))
Then
Open "SDKSequences" To SeqFile
On Error
Message = "System error (" : Status() : ") opening SDKSequences file."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End
Else
Command = "CREATE.FILE SDKSequences 2 1 4"
Command<-1> = "IF @SYSTEM.RETURN.CODE >= 0 THEN INSERT INTO DICT SDKSequences(ID,F1,LOC,F4,F5,F6) VALUES ('NextVal','D','1',NextVal','7R','S');"
Call DSExecute("UV", Command, Output, ExitStatus)
If ExitStatus = DSJE.NOERROR
Then
Open "SDKSequences" To SeqFile
On Error
Message = "System error (" : Status() : ") opening SDKSequences file."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End
Else
Message = "Unable to open newly-created SDKSequences file."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End ; * end of innter Open attempt
End
Else
Message = "Unable to create SDKSequences file."
Message<-1> = Output
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End
End ; * end of Open statement
End ; * end of test whether file already open
* Attempt to set exclusive record update lock on sequence record.
RecordLockU SeqFile, SequenceName
On Error
Message = "System error (" : Status() : ") setting lock on sequence."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End
Locked
Message = "Can not reset sequence that is locked by user number " : Status() : "."
Call DSLogWarn(Message, RoutineName)
GoTo MainExit
End ; * end of RecordLockU statement
* Write new sequence value into sequence record (which releases lock).
Write NewVal To SeqFile, SequenceName
On Error
Message = "System error (" : Status() : ") writing to SDKSequences file."
Call DSLogWarn(Message, RoutineName)
End
Then
Ans = NewVal
End
Else
Message = "Unable to write to SDKSequences file. Status = " : Status() : "."
Call DSLogWarn(Message, RoutineName)
End ; * end of Write statement
MainExit:
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Thanks for letting know that Now if one check the SDK key management routines available under Routines/sdk directory you can see how it proceeds there.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Big Statement
Everything in the SDK was put together in a hurry, and it shows.
Nearly every routine in the SDK can be improved.
Nearly every routine in the SDK can be improved.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Rightly said. As I have noted earlier I just changed one of the SDK key management routines for what OP asked. Have tested it and works fine.
Change one of the SDK key management routines available under Routines and use this in your sequence.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Have you tested the same with "KeyMgtGetNextValue" routine available under Routines/sdk directory? "KeyMgtReset" routine falls into the same category, not for concurrent update as "KeyMgtGetNextValueConcurrent" routine.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Not being the author, nor responsible for the author, I find no reason to test. If I believe an SDK routine is suitable for my purposes, I use it; if I believe it needs improvement, I create and use an improved version.
I do believe that a "reset" routine falls into the category of needing to manage locking better than the supplied routines do it.
I do believe that a "reset" routine falls into the category of needing to manage locking better than the supplied routines do it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Fair enough ! For those whose find the above routine is suitable, use it, if someone believe it needs improvement, please create and use.
ray.wurlod wrote: If I believe an SDK routine is suitable for my purposes, I use it; if I believe it needs improvement, I create and use ...
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>