Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: dbms_random package; etc

Re: dbms_random package; etc

From: Paul Harrington <paulh_at_io.com>
Date: Fri, 19 Oct 2001 12:16:06 GMT
Message-ID: <3BD01983.722A5761@io.com>

Cosmin Ioan wrote:
>
> hi all, I have a two-fold problem:
>
> a). I am trying to use the dbms_random package to get a random number and
> for some weird reason, even though initialize to a value X the Random
> function always returns a number larger then X.

If you are referring to the dbms_random.initialize procedure, all that does is set the random number generator "seed". Nothing got to do with the range within which your random number is generated.

Try passing parameters to the dbms_random.value function instead:

> b). Related to the above, I am trying to obtain a sample of records from
> let's say a 20 mill. recordset. Would using rownum with the above package
> be my fastest solution?

No, using ROWNUM will probably cause a full table scan on your 20m row table regardless of how you package your solution. Does your table have a numeric ID column at all? Could you generate a random number as above, then look up your table using this random number? I've written test packages that do this sort of thing and can send you the code used if you like.

Hope that helps,
Paul.

>
> thx much,
>
> Cosmin
>
> P.S. Unfortunately, I am constrained to whatever packages are in Oracle
> 8.1.6.2, ie, I cannot bring in outside packages.

-- 
=====================================================================
Paul Harrington - Oracle DBA/Developer, Orbiscom, Dublin.
Email:  paulh_at_io.com. Please note: I discard all BCC messages unread.
=====================================================================
Received on Fri Oct 19 2001 - 07:16:06 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US