Need Distinct Values

Fairlight fairlite at fairlite.com
Tue Jan 16 16:23:33 PST 2007


The honourable and venerable Walter Vaughan spoke thus:
> I cannot believe I cannot figure this out.
> 
> I need unique distinct values. I've done this a million times, but with a 
> smaller number of items, using a dummy field to determine and toss out dupes.

I'm assuming you could generate the value before saving the record for
later retrieval?  My method would be along the following lines:

fields
------
UQ_Date,8,MDYY/
UQ_Time,8,HMS
UQ_Idx,8,.0
UQ_Unique,20,*

Fill in the first two.

Create the contents of UQ_unique by concatenating the mids of only the
integers in the date and time fields.  That should be 12 digits long.

Do a lookup to your unique key bearing field (that should be the same def
as UQ_Unique).  Modify UQ_Unique in a GETNEXT loop by the following 
criterion:

     1) If there are no records that begin with the first part of the
        field, append a "1" to UQ_Unique and store it.

     2) If you find records that beginwith the first part of the field,
        mid() off the section between the 12th character and the end of the
        string.  Push any trailing spaces off with {"" so it's numeric only.

        2a) Add one to the resultant additional index number you obtained
            in step #2.

        2b) Append the result of step #2a onto UQ_Unique and store it.

Good for 99,999,999 unique ID's.  Expand the length of the index and the
unique field if you need more than that.

That work for you?  It -should-, so long as you're never deleting records.
Although, you could always store out to a one field table that contains
only the unique ID values and save just those forever, while allowing main
records associated with the ID to be deleted; this could have significant
space savings depending on the length of the record associated with the ID
that you're tracking with ID's, assuming you do delete.

mark->


More information about the Filepro-list mailing list