Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique ID from String

Status
Not open for further replies.

newtofoxpro

Programmer
Sep 16, 2007
301
IN
I want to generate Unique ID from String. For Example . SYS(2007,padr("HI",70))
But sys(2007) generate same id from two string.

Thanks & Best Regards.




 
Your idea in short is to SEEK(CRC32(longvalue), cAlias, cCRC32IndexTag) instead of SEEK(longvalue,cAlias, cNormalindextag), where the CRC32indextag would be an index on SYS(2007,....) and the normalindextag would just index a column or concatenated columns.

In regard of using checksums or hashes for shorter indexes Mike gives me an idea by saying:
Mike said:
But the only way to guarantee a unique value would be to generate the checksum, then scan the existing values in the table to see if the new value already exists, and then modify it if it does.[/code]

You could do a double lookup. You create a lookup table with (iID, cCRC32, cLongvalue), you SET KEY TO CRC32(longvalue) and SCAN REST FOR cLongvalue=longvalue. If not found, you add a record here with CRC32(longvalue) and longvalue stored into it, generating a new iID. If found, you use the iID of that record and obviously you are in full control to generate a unique ID value, really simply an integer id, and put these int id values in any table you'd now want to index on CRC32 checksums. Then have an index on that column and you can almost as easily seek some record by a really unique value, no matter if there are longvalues having a CRC32 value collision.

It's a doulbe lookup every time though, first in this table, then seek or query the int in the table of real interest. I doubt it really will help, but you could even define a memo field for longvalue and have an index for large values you could otherwise not index.

Bye, Olaf.
 
Hi Olaf,
Well, yes and no.
... what Whil Hentzen talked about was part of VFP samples in the newid() stored proc of the newid.dbc
But that's having a record per Database table with an individual counter. ...
It was easy to develop his idea and have one table per project. And that's what I did.

Bye
MK
 
MK,

>It was easy to develop his idea and have one table per project. And that's what I did.
You still don't see things:

1. VFP3 had no autoinc, also not a problem with it being readonly
2. I didn't say newid is needing multiple tables, your answer "and have one table per project" is suggesting newid needs more than one per project.

My idea alos just has one table, and it has no records at all in it.

Bye, Olaf.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top