Generating a Unique Identifier
July 26, 2002 Timothy Prickett Morgan
I just read your article, “Using Timestamps as Unique Keys,” in the July 17 issue of Midrange Guru, OS/400 Edition.
There might be a better way of creating a unique ID, one that doesn’t require retries. It’s the GENUUID API and/or MI built-in.
Universal Unique Identifier (UUID) is supposed be a totally unique ID, even across all the machines in the entire world. I’m assuming that in reality this is 100 percent true, but I wouldn’t worry about it.
Here’s some code that I’ve had stashed away:
H option(*NoSrcStmt) DftActGrp(*No) D UUIDTemplate ds D BytesProv 10u 0 Inz(%Size(UUIDTemplate)) D BytesAvail 10u 0 D 8a Inz(*Allx'00') D UUID 16a D GenUuid pr ExtProc('_GENUUID') D Template * Value C callp GenUuid( %Addr(UUIDTemplate)) C eval *inlr = *on C return
After the CALLP, UUID should contain a unique value.
For more technical information about UUIDs, read the Internet Engineering Task Force (IETF) memo, “UUIDs and GUIDs“
ADVANCED SYSTEMS CONCEPTS
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based AS/400 and iSeries data access can be! In just a few short minutes, you can find out ways to make your job easier and improve data access throughout your organization. Download the ViewPoint movie here .
For more information or a FREE trial of SEQUEL, call 847/605-1311 or visit Advanced Systems Concepts.