IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Problem in Unique Id generation using RANDOM


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Mon Jan 27, 2014 7:34 am
Reply with quote

This program is running million times a day and possibilities of running multiple times in a same TIME-STAMP.

So, I don't want to create a file/db-table to fetch the value and worry about these things.
1. Waste of resource (file/db)
2. Waste of process (read & update file/db)
3. Waste of CBU time (since I/O operation)
4. Cause of Deadlock.

A simple RANDOM function with unique seed would do my needful. It would be much faster then getting "next available number".

I'm sure "next available number" method will work on normal program that runs minimum times. Appreciate your suggestions icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jan 27, 2014 7:58 pm
Reply with quote

Hello,

A million executions is not so many . . .

Also, i'll wager that using a file/table will add almost invisible overhead compared to whatever this process does.

Why do you believe the random number would be free?

If the next available number is in a file/table, it may never leave memory and there would be only logical i/o, not physical i/o.

There should be no chance for a deadlock if the code is properly implemented. If the code was written to get the next available as the first part of the code (and commit the change), the chance of a time-out is Greatly reduced if not eliminated.

Sounds like you already decided you want to use random. Keep in mind that this Can cause a duplicate that has to be dealt with.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jan 27, 2014 9:01 pm
Reply with quote

In the CICS Forum, review the Sticky program DATETIME

ibmmainframes.com/viewtopic.php?t=61935

It's for CICS only (can be modified to be for Batch as well).

The Timestamp granularity is down to the microsecond.

If you combine the Date/Time (date-packed is PL5'0CCYYMMDD' and the time-packed is PL13'0HHMMSSTHMIJU"), together with the Task-Number as a PL4, you have a unique random number.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts DFHPI1008 JSON generation failed COBOL Programming 0
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top