Unique number generation Logic
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Application Programming

#1: Unique number generation Logic Author: nagapa PostPosted: Thu Oct 20, 2005 7:44 am
    —
Hi,
I have a requirment to write a cobol stored proc that needs to generate a unique number. There could be multiple instatnce of the same procedure and each one should have a unique number. This number is used to udpate some db2 tables where this field is the key.

Can anyone suggest a logic for this.

The number generated should be 9(9).

#2:  Author: nagapa PostPosted: Thu Oct 20, 2005 8:09 am
    —
Kolusu,
Think I have posted this in the wrong place.... I am working on the logic and looking forward for inputs from experts here...

Can I move this to other topics... I tried to edit it but cant

Regards
Nagapa

#3:  Author: kolusuLocation: San Jose PostPosted: Thu Oct 20, 2005 8:16 am
    —
Quote:

This number is used to udpate some db2 tables where this field is the key.


Nagapa,

why not define the field as Autogenerated in the table itself? You use the ROWID data type to uniquely and permanently identify rows in a DB2 subsystem. DB2 generates a value for the column when a row is added. You can use direct-row access so that DB2 accesses a row directly through the ROWID column. If an application selects a row from a table that contains a ROWID column, the row ID value implicitly contains the
location of the row. If you use that row ID value in the search condition of subsequent SELECT statements, DB2 might be able to navigate directly to the row.

Kolusu

#4:  Author: nagapa PostPosted: Thu Oct 20, 2005 8:27 am
    —
Hello Kolusu,
at the moment we have a id_table that holds 10 records with unique value. Our stored proc, pics a value (based on ur login ind, if ur ids last numeric digit is 1, take the value from line 1). and update that table with new value (increment the current value by 1).
There are a lot of users, and this logic cannot cope with volume. We get -913 quite often. We change the table from table lock to row lock. The abends have reduced but still prevails...

we are looking for a logic that could help us generate unique numbers instead of using this table.
Also we cannot go for autogenerated as this id is not the full key for other table but needs to be unique.

Thanks
Nagapa

#5:  Author: kolusuLocation: San Jose PostPosted: Thu Oct 20, 2005 8:51 am
    —
Nagapa,

Do you need the generated id to be incremental or just unique ? If it is just unique then you can use the TIMESTAMP field in DB2. Use the Microseconds portion timestamp field to generate the unique ID.

Kolusu

#6:  Author: nagapa PostPosted: Thu Oct 20, 2005 9:12 am
    —
Hi Kolusu,
I need it unique but sequential.

can we use CREATE SEQUENCE.... I have never used it before.



MVSFORUMS.com -> Application Programming


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group