Solved

Retrieve Random value for each requests

Posted on 2006-11-20
5
492 Views
Last Modified: 2008-02-01
All,

I want to retrieve random records for each transaction. Like for first transaction, I want to retrieve first set of five and second a second set of five. How do i do that ?

I use Oracle 10.2

Thanks
0
Comment
Question by:shreyamenon
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 50 total points
ID: 17985376
Use the following: Replace A2 with your table name and put your column names in the select list:

select id, name
from
(
select m.*, rownum r from A2 m
)
where r in
(select round(dbms_random.value(1,(select count(*) from A2))) from user_tables
where rownum < 6)
0
 

Author Comment

by:shreyamenon
ID: 17987289
Sujith,

Thanks for your reply.
dbms_random gives me this error: ERROR at line 1:
ORA-00904: : invalid identifier

Looks like this is not initialized. What can /shall I do to start using this package ?

Thanks


0
 
LVL 27

Expert Comment

by:sujith80
ID: 17993551
do the following

desc dbms_random

select dbms_random.value(1,100) from dual;


and let me know
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
one-way data "masking" MD5 sql 26 145
Oracle regular expression 6 45
case statement in where clause 5 40
Oracle - Create Procedure with Paramater 16 56
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now