Subject Re: Random Records
Author Ian A. Newby
Hi Lester,
You could try this...

Create a table

create table random (
mykey integer not null,
random double precision
)
index both fields seperately
.

Create an after insert trigger to populate it with the key and a
random number on record creation of your key table.

create a sp, called nextRandom
similar to..

CREATE PROCEDURE SP_NEXT_RANDOM(
RETURNS (
MYKEY VARCHAR(15))
AS
declare variable zeros varchar(10);
begin
select first 1 mykey from random into :mykey;
delete from random where key = :mykey;
suspend;
mykey = null;
select first 1 mykey from random into :mykey;
if mykey = null then
insert into random (key, random) select key, rand() from mytable;
end
end

use select * from mytable where id = (select mykey from
sp_next_random) to get the next random record.

This method means that you get no repeats until the all the records
have been given in a random order.

Regards
Ian Newby