Page 1 of 1

KeyMgtGetNextValue Usage

Posted: Mon Nov 15, 2004 7:12 pm
by anilkona
Hello,

Can someone point me to the correct usage of KeyMgtGetNextValue() routine. I see in the definition there is a parameter to this routine. How do we define this parameter? Do we have to pass a constant number value as the argument or is there a place to define the variables and pass that as an argument?

Thanks in advance for the help

Posted: Mon Nov 15, 2004 7:48 pm
by rasi
Hi

KeyMgtGetNextValue() is the special routine which will generate sequential numbers. You need to pass the string as parameter and it will be stored inside SDKSequences universe table. This prameter is unique and you cannot have duplicate name. The string is case sensitive. Each time you use this function along with the parameter it will read from the universe and will increase the value in increment and will output the incremented value.

Whenever you want to reset this then you need to update the value in universe.
Syntax:
UPDATE SDKSequences USING DICT VOC SET F1 = 'New_Value' WHERE @ID = 'Sequence_Name';

Thanks

Re: KeyMgtGetNextValue Usage

Posted: Tue Nov 16, 2004 3:42 pm
by ranga1970
anilkona wrote:Hello,

Can someone point me to the correct usage of KeyMgtGetNextValue() routine. I see in the definition there is a parameter to this routine. How do we define this parameter? Do we have to pass a constant number value as the argument or is there a place to define the variables and pass that as an argument?

Thanks in advance for the help
You do not need pass constant, this is usually used for one time loads, fro eaxample you have record
col1 col2 col3
a 1 A1
b 2 B1

when you use keyMgt... and run your job for first time your output
col1 col2 col3 col4
a 1 A1 1
b 2 B1 2

but by any chance if you have to rerun the job your output will be

col1 col2 col3 col4
a 1 A1 1
b 2 B1 2
a 1 A1 3
b 2 B1 4

which make your records distinct so either you have to reset KEY in SDK every time you run or use @InrowNumber or @OutrowNumber depending on your situation

you can reset your key in SDK if you use KeyMgt.... as Siva said above

Thanks

Posted: Tue Nov 16, 2004 4:39 pm
by anilkona
Thanks Ranga and Siva for explanation

Posted: Tue Nov 16, 2004 5:02 pm
by chulett
As an FYI, these SDK routines are documented, some better than others - check out the Short and Long Descriptions in their properties. For example, this routine says:
Sequence number generator.
Routine to generate a sequential number. This routine does not support access to a particular sequence by more than one process concurrently. The routine argument is the name associated with the sequence. The routine uses a file to store the next available number. It reads the number once, then increments and stores the value in common, writing the next value back to file each time.
By 'file' it means hash file. You can also read the code to get a better understanding of what it does and how it does it.

Some caveats: It does require a constant value be passed to it if you are expecting a useful series of numbers to come back from it. Each parameter value passed in becomes a key to the hash it uses and starts a new series of numbers if that key doesn't already exist, otherwise you get the next number in sequence for that key. Lastly, because it uses COMMON storage, it is not recommended for use in jobs that take advantage of Row Buffering.