Home » SQL & PL/SQL » SQL & PL/SQL » how to generate random records
how to generate random records [message #35607] Mon, 01 October 2001 03:23 Go to next message
Sangeeta
Messages: 9
Registered: October 2001
Junior Member
i have a table that stores questions.
i need to generate questions randomly so that each time a student sits for the test he gets a different set of questions each time

i'll be very greatful if anyone could help me.
i tried using the get_hash_value function but didn't achieve the purpose.

the dbms_random package is too inefficient .i need a better solution

----------------------------------------------------------------------
Re: how to generate random records [message #35614 is a reply to message #35607] Mon, 01 October 2001 09:03 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Why do you feel that the dbms_random package is inefficient?

----------------------------------------------------------------------
Re: how to generate random records [message #35618 is a reply to message #35607] Mon, 01 October 2001 14:53 Go to previous messageGo to next message
oraboy
Messages: 97
Registered: October 2001
Member
I guess, you can write a simple procedure to pick a random no (with an algorithm which uses time component)

al you need to include a few more lines to ensure same question is not repeated again in the same test

Oraboy

----------------------------------------------------------------------
Re: how to generate random records [message #35620 is a reply to message #35618] Mon, 01 October 2001 15:22 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Why reinvent the wheel? I still don't understand his comment that DBMS_RANDOM is "inefficient". It's sole purpose is to generate random numbers and it does so very efficiently.

----------------------------------------------------------------------
Re: how to generate random records [message #35648 is a reply to message #35607] Wed, 03 October 2001 20:35 Go to previous messageGo to next message
Sangeeta
Messages: 9
Registered: October 2001
Junior Member
hi todd,
The reason why i feel that dbms_random package is inefficient is that...
"If you need 100 records, get 100 random numbers using dbms_random package and read until the rownum equals the random number".The inefficiency lay in the fact that if your random number generator selected rows 500, 10000 and 2000 you need to read 12500 records to get at those 3 random records. As the number of random records you require gets bigger, the overhead associated with this method becomes massive.
todd i still have no clue of how to decrypt my data(this is what i had asked in my previous query)

hope to hear from u soon

----------------------------------------------------------------------
how can I use the dbms_random package? [message #35744 is a reply to message #35607] Thu, 11 October 2001 10:02 Go to previous messageGo to next message
Bernd
Messages: 2
Registered: October 2001
Junior Member
I need a function which selects 150000 records from a table with 3Mio records random. How can I do this. Thanx for help!

----------------------------------------------------------------------
Re: how can I use the dbms_random package? [message #37919 is a reply to message #35607] Wed, 06 March 2002 07:00 Go to previous message
kim
Messages: 116
Registered: December 2001
Senior Member
Bernd,
Were you able to come up with the routine for this yet? If yes, how did you do it?

thanks,
-kim
Previous Topic: Create table from existing table
Next Topic: Re: Extremely high Consistent Gets and DB Buffer Gets
Goto Forum:
  


Current Time: Thu Apr 18 08:42:09 CDT 2024