Subject Re: [firebird-support] selecting a random record within the db
Author Alexandre Benson Smith
rebel_rob_98 wrote:

>Hello All,
>
>I would like to select a random record from a table and return the
>results on a web page. I can do this with ASP however it requires a
>couple of trips to the database (which I am hoping to avoid). I was
>hoping to accomplish this selection within a view or stored procedure.
> However, I can not find any information regarding the availability of
>rnd() or random() for firebird.
>
>I am running firebird superserver 1.5.2
>
>Any tips or suggestions would be greatly appreciated.
>
>Thank you for your time.
>
>
You can declare an UDF.

/*****************************************
*
* r a n d
*
*****************************************
*
* Functional description:
* Returns a random number between 0
* and 1. Note the random number
* generator is seeded using the current
* time.
*
*****************************************/
DECLARE EXTERNAL FUNCTION rand
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_rand' MODULE_NAME 'ib_udf';



--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.5 - Release Date: 07/06/2005