Lol Now you've opened up the "GOTO" or "LOOP REPEAT" debate. :-)
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of DAVID WADEMAN Sent: Thursday, April 24, 2008 10:58 AM To: u2-users@listserver.u2ug.org Cc: u2-users@listserver.u2ug.org Subject: RE: [U2] Guaranteed unique sequential keys I had this issue where I was overwriting files and found out that I need to used @ rather than the (). I know there a difference in using time/date where : @DATE [EMAIL PROTECTED] is when the user/phantom was logged in DATE() {TIME()} is the actually time and date I got around this by using this to write to the file: XKEY = @LOGNAME:"*":DATE():"*":TIME() Then I can create VF like X.DATE I FIELD(@ID,@VM,2) D2/ Date 20L S X.TIME I FIELD(@ID,@VM,3) MTH Time 20L S Also you can avoid 2 processes not writing to the same file by inserting this right before you write to the file and/or to make sure also you can: X.DATA = "Something" DO_AGAIN: XKEY = @LOGNAME:"*":DATE():"*":TIME() READ XFILE.REC FROM F.XFILE, X.KEY THEN SLEEP(1) GOTO DO_AGAIN END ELSE WRITE X.DATA TO F.XFILE, X.KEY END This is Unix and UniData (not sure with the rest) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere Sent: Thursday, April 24, 2008 5:55 AM To: u2-users@listserver.u2ug.org Subject: [U2] Guaranteed unique sequential keys What is the most reliable way to generate unique sequential keys without having to resort to a record on disk updated through readu/write? The keys don't have to be contiguous but only be sortable in the order in which they were generated by several phantom processes running concurrently. I'm currently approximating this using a concatenation of date and time with millisecondsB but I'm worried about the possibility of two phantoms generating exactly the same key. B Although no collision has been detected so far, I have added an extra check where after generating the key I first test if a record with that key exists. If so IB increment and append aB serial number and repeat the test until aB unique key is found. ItB seems to be working well but I still think there is a better way to do this. B Thanks for any help. B Marco. __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/