Solved

Retrieve Random value for each requests

Posted on 2006-11-20
5
491 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
Comment Utility
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
Comment Utility
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
Comment Utility
do the following

desc dbms_random

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


and let me know
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to take different types of Oracle backups using RMAN.

772 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

9 Experts available now in Live!

Get 1:1 Help Now