Solved

Retrieve Random value for each requests

Posted on 2006-11-20
5
496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creation date for a PDB 5 87
add more rows to hierarchy 3 48
return value in based on value passed 6 50
Oracle database T-1 Setup 7 45
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

710 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