[Openroad-users] Random Function

Doug White black_belt101 at hotmail.com
Sat Dec 15 15:11:41 EST 2007


That is much nicer, 

Is there a way I can get a random seed if my app doesn't connect to a database?

Doug


Date: Fri, 14 Dec 2007 08:14:39 -0500
From: Sean.Thrower at ingres.com
To: openroad-users at peerlessit.com
Subject: Re: [Openroad-users] Random Function






















Apologies – I should have been
clearer – I meant that you use the OpenROAD-local random() function
throughout, having first got a random seed from the database call: but you do
it by using each locally-generated random number to set limits for the next
one, so as to avoid the situation where  the OpenROAD-local random() starts
from the same seed each time at application startup.

 

Initially:-

query = ‘SET RANDOM_SEED ’ + :whatever;                                        //optional

EXECUTE IMMEDIATE :query;                                                              //optional

SELECT random(:low, :high) AS randy;

 

Thereafter:-

low = lowfunction(randy); high = highfunction(randy);

randy = random( :low, :high);

 

On reflection, it may even suffice to base
the limits on the database-generated seed just once, since thereafter the
random number sequence is emerging from a randomly chosen limit-set, so is
randomly different from every other application startup.

 

Initially:-

query = ‘SET RANDOM_SEED ’ + :whatever;                                        //optional

EXECUTE IMMEDIATE :query;                                                              //optional

SELECT random(:low, :high) AS randy;

low = lowfunction(randy); high = highfunction(randy);

randy = random( :low, :high);

 

Thereafter:-

randy = random( :low, :high);

 

Sean.

 









From:
openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Kim Ginnerup

Sent: Friday, December 14, 2007
12:01 PM

To: International OpenROAD Users

Subject: Re: [Openroad-users]
Random Function



 

If you can find the old
tetris demo app for OpenROAD

You will find that
OpenROAD actually has a built in random function

 

Kim

 









Fra:
openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] På vegne af Sean Thrower

Sendt: 14. december 2007 12:12

Til: International
 OpenROAD Users

Emne: Re: [Openroad-users] Random
Function



 

Or maybe use the execute immediate select
just to get the first random number, then derive the next limit-values from
each random value in turn – random()-generated values from random limits
should be random … - using Mod if necessary to bring the final working
value into range.

 

Sean.

 

Sean Thrower

Ingres Premium Services

 

 









From:
openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com]
On Behalf Of Bodo Bergmann

Sent: Friday, December 14, 2007
9:01 AM

To: International
 OpenROAD Users

Subject: Re: [Openroad-users]
Random Function



 

Or you coud just use the Ingres random()
functions (see SQL Ref Manual)

using a select (Execute Immediate if not
supported directly).

 

Bodo Bergmann

Senior Software Engineer

OpenROAD Worldwide Engineering

Ingres Corp.

 







From:
openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Doug White

Sent: Friday, December 14, 2007
9:02 AM

To: openroad

Subject: [Openroad-users] Random
Function

Hey All,



I finally got sick of the crappy support for random number generation in
OpenROAD, So hopefully this can be of use to someone.



Enjoy, and please email me if you spot any problems / improvements that can be
fixed



P.S It's an exported application, that will probably only work in XP



Doug White



 







Listen now! New music from the Rogue Traders. 







_________________________________________________________________
Your Future Starts Here. Dream it? Then be it! Find it at www.seek.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau%2F%3Ftracking%3Dsk%3Ahet%3Ask%3Anine%3A0%3Ahot%3Atext&_t=764565661&_r=OCT07_endtext_Future&_m=EXT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071215/74b45d6d/attachment.html 


More information about the Openroad-users mailing list