Subject How to use rand()?
Author weiwufeng
I want to use rand() function to get a random row from a FORTUNE table.But I always get same a row when I reconnect to my database.
The function description tell me:"Note the random number generator is seeded using the current time."
Why I always get same row? How I change the seed?

It is Firebird-2.0.3.12981-1-Win32.exe that I use.

/*****************************************
*
* 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';


SET TERM ^ ;
ALTER PROCEDURE GET_RANDOM_FORTUNE
RETURNS (
FORTUNE Varchar(1000) )
AS
BEGIN
SELECT FIRST 1 FORTUNE
FROM FORTUNE
ORDER BY rand()
INTO :FORTUNE;
SUSPEND;

END^
SET TERM ; ^


--
weiwufeng <blackspace@...>