> Paul Nelson wrote:
> A client has posed an interesting problem. His employee master file
> contains a 2 digit company number, a 3 digit division number, and a
> 5 digit employee number. He needs to have some math done to generate
> a unique 7 digit number.
Don wrote:
Something tells me that there's a hash out there that could do the trick for
you here..
A one-way hash was the first thing that came to mind for me too. Paul
could use the Qc3CalculateHash (QC3CALHA) API in an SQL stored
procedure. However, there are a couple of potential problems with this
approach.
1. The shortest possible hash value using the API comes from the MD5
algorithm. The length of an MD5 hash is 16 bytes. Paul would still
need to map from this hash value to a 7 digit number, introducing more
opportunity for collisions. Of course, it should be possible to test
for every possible combination of company number, division and employee
number, but it might take far too long.
2. It isn't feasible to go from the hash value to the number. It is
unclear whether round-tripping is a requirement or not.
3. The Qc3CalculateHash API wasn't introduced until V5R3.
Hope this helps,
Adam