Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: dbms_random package; etc
thanks v. much Paul. helps to investigate the package funcs/procs :-)
"Paul Harrington" <paulh_at_io.com> wrote in message
news:3BD01983.722A5761_at_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:
> -- get a random Oracle number x, low <= x < high
> FUNCTION value (low IN NUMBER, high IN NUMBER) RETURN NUMBER;
>
> > 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 - 09:24:08 CDT
![]() |
![]() |