Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieve Random value for each requests

Posted on 2006-11-20
5
Medium Priority
?
506 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 200 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

705 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