query a table with results in random order

Thorsten Hohage thohage at objectmanufactur.com
Thu Dec 20 16:35:15 CST 2007


I'm afraid that you alway get the data back in a generic or specific  
order.

So IMHO you've got four different options

a) When you're talking about a single user app, you can define a order  
column and update this column with new randoms and then do the select  
in a second step

b) Use a stored procedure

c) Use a temp table - perhaps even in a on-the-fly-in-memory db - and  
create their a pair of order column and recID. This is preferable  
because it's multi-user and you don't going to change permanently the  
db w/o any real need

d) Same strategy like c. But you request the list of recIDs first.  
Then you resort these recIDs and loop about this array to fetch the  
record by record in a reordered way. There might be better options,  
e.g. I would use a Dictionary in RB and do a full fetch, but I didn't  
know about Director.


Keep in mind, that randoms are often NOT random!!!! There is some more  
or less fancy staff to produce "pseudo-random" numbers, but especially  
if this test is played again and again the order might be predictable.  
Perhaps someone of the engineers can jump in here and say a word about  
the quality of Valentina randoms.

On 2007-12-20, at 22:28, Czajka, Mark wrote:

> I want to query a database, but get the results back in a random order
> for a testing application (randomize the order of the questions). I  
> have
> the questions and their answers stored in a Valentina db/table and I'm
> using Director. Could anyone provide some tips on how they would solve
> this problem? Would this utlize a random cursor or some other  
> function.
> Thanks for any help you could provide.
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina


regards

Thorsten Hohage
--
objectmanufactur.com - Hamburg,Germany




More information about the Valentina mailing list