Subject Re: [firebird-support] How to use rand()?
Author blackspace@163.com
Thank you.But It still get a same row.
If the solution dont work,then I have to add a column to the fortune table.
I think my application reconnects the database when to call the SP ,so the seed is same.
If I use a connection to call many time the sp, these rows are't same.

SET TERM ^ ;
ALTER PROCEDURE GET_RANDOM_FORTUNE
RETURNS (
FORTUNE Varchar(1000) )
AS
Declare num INTEGER;
BEGIN

SELECT count(*)
FROM FORTUNE
INTO :num;

num = rand() * num;

FOR SELECT FIRST (:num) FORTUNE
FROM FORTUNE
ORDER BY FORTUNE
INTO :FORTUNE
do
begin
end
SUSPEND;

END^
SET TERM ; ^