Subject | Re: Does FB 1.5 support RAND function? |
---|---|
Author | Adam |
Post date | 2006-06-03T03:45:12Z |
--- In firebird-support@yahoogroups.com, <myles@...> wrote:
Return a random record from the table? If so I imagine you could read
the current generator value and use a UDF function to get a random ID
in that range for the table. It is possible it may return a 'not yet
committed' or 'since been deleted' value, so you will need to put some
sort of retry logic, and an abort (ie choose the first record) if a
significant number or retries fail. This could all be done within a
stored procedure.
Of do you mean return a random number between 0 and 1? If so, I am
sure you will find a UDF to help you out.
Again, a simple example of the sort of thing you are trying to do will
make it easier to suggest a good way of doing it.
Adam
>book, by
> According to the documentation in 'The Firebird Book' (brilliant
> the way), the RAND function is not supported in Firebird 1.5. Isthere an
> alternative to this function that I can use?What does this function do?
Return a random record from the table? If so I imagine you could read
the current generator value and use a UDF function to get a random ID
in that range for the table. It is possible it may return a 'not yet
committed' or 'since been deleted' value, so you will need to put some
sort of retry logic, and an abort (ie choose the first record) if a
significant number or retries fail. This could all be done within a
stored procedure.
Of do you mean return a random number between 0 and 1? If so, I am
sure you will find a UDF to help you out.
Again, a simple example of the sort of thing you are trying to do will
make it easier to suggest a good way of doing it.
Adam