Re: How to generate specified Random

From: (wrong string) é Nicolau <jnicolau_at_hotmail.com>
Date: 1998/08/16
Message-ID: <35D6A387.32EF7FE_at_hotmail.com>#1/1


Try this (semi SQL semi pseudo code)

select count(*) into specialists

    form doc_table
    where doc_specialty = 'Cancer'; -- and this my be a parameter

n := 1;
n_stop := rand_max (specialists); -- as in -- http://www.oracle.com/st/products/features/random_down2.html

for doc_register in (select * from doc_table where doc_specialty = 'Cancer')
loop

    if n = n_stop
    then

--        I have my specialist in doc_register;
        exit when 0=0;

    end if;
    n := n + 1;
end loop;

Johnny Tjokro wrote:

> Hi,
> I have ORACLE 7.3.3.4 that is sitting on UNIX
> The script that I am working on is :
>
> Let say I have lists of doctor's names. Each list is group by the
> doctor specialty.
> i.e. : Cancer, Plastic Surgery, Radiology, Dentist etc.
>
> What I am trying to achieve is :
> Let say I want to find a Dentist. And there are 2000 dentists on the
> list.
> Therefore, the script should randomly pick one out of 2000.
> OR
> I want to find a Radiologist. There are 300 radiologists on the list.
> Therefore, the script should randomly pick one out of 300.
>
> Any help would be appreciated.
Received on Sun Aug 16 1998 - 00:00:00 CEST

Original text of this message