Generating random sets of values
153833Oct 24 2005 — edited Oct 26 2005Hi 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!