Subject | rand() of ib_udf not so random? |
---|---|
Author | valenciaraul2004 |
Post date | 2004-01-16T04:18:36Z |
Hi, FBExperts! ;-)
I'm running Firebird 1.0.3 in an updated SuSE 8.1 installation (kernel
2.4.21-151, glibc 2.2.5).
I have attached to my database the rand() function that is in ib_udf:
DECLARE EXTERNAL FUNCTION RAND
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_rand' MODULE_NAME 'ib_udf';
and I have the following procedure that is intended to return five
random numbers:
SET TERM ^;
CREATE PROCEDURE R_NUM_LIST
RETURNS
(
RNUMBER DOUBLE PRECISION
)
AS
begin
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
end
^
SET TERM ; ^
The records returned when I do a SELECT RNUMBER FROM R_NUM_LIST have
always the same number, repeated five times, although it is different
every time I run it.
I'm doing something erroneously?
Many thanks for your help.
I'm running Firebird 1.0.3 in an updated SuSE 8.1 installation (kernel
2.4.21-151, glibc 2.2.5).
I have attached to my database the rand() function that is in ib_udf:
DECLARE EXTERNAL FUNCTION RAND
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_rand' MODULE_NAME 'ib_udf';
and I have the following procedure that is intended to return five
random numbers:
SET TERM ^;
CREATE PROCEDURE R_NUM_LIST
RETURNS
(
RNUMBER DOUBLE PRECISION
)
AS
begin
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
rNumber=rand();
suspend;
end
^
SET TERM ; ^
The records returned when I do a SELECT RNUMBER FROM R_NUM_LIST have
always the same number, repeated five times, although it is different
every time I run it.
I'm doing something erroneously?
Many thanks for your help.