Article View: borland.public.interbase.sql
Article #485Re: How to use rand() function?
From: blackspace
Date: Thu, 06 Dec 2007 09:19
Date: Thu, 06 Dec 2007 09:19
49 lines
1963 bytes
1963 bytes
It is Firebird-2.0.3.12981-1-Win32.exe that I use. On Thu, 6 Dec 2007 17:12:56 +0800 blackspace@163.com wrote: > I want to use rand() function to get a random row from a FORTUNE table. > 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? > > /***************************************** > * > * 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 ; ^ > > > -- > <blackspace@163.com> -- <blackspace@163.com>
Technical Details
Message-ID:
<20071206171948.47afde58.blackspace@163.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<20071206171256.d88a1845.blackspace@163.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,d0f8446ede906db X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 6 Dec 2007 17:19:48 +0800 From: blackspace@163.com Newsgroups: borland.public.interbase.sql Subject: Re: How to use rand() function? Message-ID: <20071206171948.47afde58.blackspace@163.com> References: <20071206171256.d88a1845.blackspace@163.com> X-Newsreader: Sylpheed 2.4.7 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 61.52.230.153 X-Trace: newsgroups.borland.com 1196932789 61.52.230.153 (6 Dec 2007 01:19:49 -0700) Lines: 49 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail