Board index » delphi » Sorting by calculated fields

Sorting by calculated fields

I want to be able to "shuffle" into random order the records of a
database table.  Normally, there will be < 100 records, and I'll
need to reshuffle the records periodically.

Suggestions?

  ++++
  |||+
+-++++-+

---
 * OLX 2.2 * Help

 

Re:Sorting by calculated fields


Quote
> joe.pars...@bbc.org (JOE PARSONS) wrote in article

<8C2C1E8.035C0010B9.uu...@bbc.org>...

Quote
> I want to be able to "shuffle" into random order the records of a
> database table.  Normally, there will be < 100 records, and I'll
> need to reshuffle the records periodically.

> Suggestions?

Define an index for the database on a dummy integer type, simply go
through and replace the values of the indexed field with random values
every once an a while.  If you want the records in 'scrambled' order,
simply apply the index.  If you want them in their original order, remove
the index.  (Both can be done at run-time.)  I wouldn't use the primary
key, though, as the primary key must be unique (at least in Paradox),
which may cause key violations when in the process of re-assigning the
values...

--
David S. Becker
ADP Dealer Services (Plaza R&D)
mailto:d...@plaza.ds.adp.com
(503) 402-3236

Re:Sorting by calculated fields


DSB> > I want to be able to "shuffle" into random order the records of a
DSB> > database table.  Normally, there will be < 100 records, and I'll
DSB> > need to reshuffle the records periodically.
DSB> >
DSB> > Suggestions?

DSB> Define an index for the database on a dummy integer type, simply go
DSB> through and replace the values of the indexed field with random values
DSB> every once an a while.  If you want the records in 'scrambled' order,
DSB> simply apply the index.  If you want them in their original order, remove
DSB> the index.  (Both can be done at run-time.)  I wouldn't use the primary
DSB> key, though, as the primary key must be unique (at least in Paradox),
DSB> which may cause key violations when in the process of re-assigning the
DSB> values...

Thanks, David.  I'll give that solution a try.
  ++++
  |||+
+-++++-+

---
 * OLX 2.2 * It's an empirical question...

Other Threads