|Subject||Re: [firebird-support] Re: Random Records|
> I have tried the obvious solution, and of course it does not work :-)The Rand() function is fixed in FB2, I think you can use it in FB1.5 too.
> I declared the Rand UDF and tried
> A.A, Rand()
> order by
> The order of the records are always the same since Rand Returns the same
> value for all records, the result tend to be identical to a select
> without an order by.
> But, What about if you try to write an UDF that returns random numbers
> not based on system time (as rand do) and use the previous number as a
> seed for the next one ?
But the above statement will always read whole table !
Lester, do you need "single select statement" solution ?
Can you afford to create generator that would remember last used ID
on each request ? Or just simply do something like
select first 1 * from ... where id > gen(last_id, 7) order by id
and reset generator if no record is returned ...