SYSTEM(1048) returns a numeric value that will be unique for all calls to this function until the next time QM is completely
restarted.
Hi Kevin,
Although you have found the answer, SYSTEM(1048) is only unique until QM is completely restarted. It is good for unique ids that do not need to survive a restart. On the other hand, GUID values are supposed to be globally unique for all time.
Martin
--
You received this message because you are subscribed to the Google Groups "OpenQM" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/openqm/-/MRynhcCuqnEJ.
Developers need to be careful about relying on System(1048). If the power goes out you don't want that being used as the ID for a work file that isn't re-initialized on a job restart.
System(12) might still be the best option for a value which is unique to the system, as it survives a reboot. However, I think this is unreliable at least one per year for a period of one hour when Daylight Saving time kicks off and we "fall back".
Heck, even the combination of System(12):System(48) is not perfectly unique if the system crashes during that one hour of the year.
The only way to ensure unique item IDs is still to generate the ID, Read on the target file, and re-generate if the item exists. This is probably as painful as generating a GUID.
So at the risk of being too "picky" about this, what are other options for a reliable unique value that isn't as painful as a GUID?
Personally I prefer all-numeric values. I wish we had a version of System(12) that returned an incrementing numeric rather than alpha:
Now: 16772992C
Numeric: 16772992.3
For sorting purposes I also wish we had a System(12) that masked the time on zeros:
Now: 1677200992.3
(Might those be 1049 and 1050?)
Because I write cross-platform utilities, I don't rely on any system mechanisms in the application code itself. I call to a common Included or Called subroutine:
GOSUB GET.UNIQUE
KEY = PREFIX:UNIQUE ; * or similar
So if I move the code to a different platform I can take advantage of new features like 1047 and 1048 without having to change any in-line app code. _That_ code might do a file lookup to ensure unique values, etc, removing this responsibility from the in-line code.
But we shouldn't need to do stuff like that… *sigh*
T
System(12) might still be the best option for a value which is unique to the system, as it survives a reboot.
Whoops, yeah, RU9999/12/19 - thanks. (Time for second cup of coffee…)