Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generating random sets of values

153833Oct 24 2005 — edited Oct 26 2005
Hi folks,
I want to generate random sets of values to test some application functionalities based on existing datas.

Let's say I want to output a list of employees. These employees has several tasks assigned to them.
I want to create a query that will generate the ID of the tasks based on the content of the task table instead of grabbing them in the tables where they will be put (later on because the employees and the tasks data aren't yet linked)...

So, it would look like this:

EMP1, TASK1 <=== Random value taken from TASKTABLE
EMP1, TASK3
EMP1, TASK6
EMP1, TASK9
EMP2, TASK12
EMP2, TASK2
EMP2, TASK3
EMP3, TASK5
EMP3, TASK21
EMP4, TASK23
EMP5, TASK54

I Tried this but I always get the same value for all records:

SELECT EMPID, NAME, (
SELECT JOB_NO
FROM (
SELECT JOB_NO
FROM TASKTABLE
order by dbms_random.value)
WHERE ROWNUM < 2) AS JOB_NO
FROM EMPLOYEETABLE

Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2005
Added on Oct 24 2005
2 comments
213 views