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: Selecting a random row from a table

Re: Selecting a random row from a table

From: Jerry Gitomer <jgitomer_at_hbsrx.com>
Date: Mon, 7 Jun 1999 12:36:52 -0400
Message-ID: <7jh3c8$mvs$1@autumn.news.rcn.net>


Hi Paul,

    Depending on the number of rows you plan to retrieve and the size of the table you may be better off generating a random number and then converting it into a rowid. (Not very pretty but it may save you some I/O.)

regards

Jerry Gitomer



Paul Davies wrote in message <375bebdf_at_newsread3.dircon.co.uk>...
>Well since no one has replied here's my suggestion - which I find rather
>messy:
>
>Use a cursor to select the data into a vararray
>
>Get a random number between 1 and count(*) - using the rand_int function
>from technet.
>
>Get the value of the vararray with an index equal to that of the random
>number
>
>Anyone got any better suggestions??
>
>
>
>
>Paul Davies wrote in message <375939d2_at_newsread3.dircon.co.uk>...
>>I'm wish a select a single row randomly from a table.
>>
>>Can someone tell me how to do this using PL/SQL?
>>
>>Thanks
>>
>>Paul
>>
>>
>
>
Received on Mon Jun 07 1999 - 11:36:52 CDT

Original text of this message

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