Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieve Random value for each requests

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.

927 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