I have been trying to achieve this in SQL (Oracle 11g) for a while but could not find a proper way to do it.
My table names
has the following rows:
Try this:
select * from names
cross join (select rownum n from dual
connect by level <= (select max(repeat) from names))
where n <= repeat
order by name
You may use some temp table containing list of numbers 1 to N, where N is the highest number in your table names
. Let call it num(o int)
Then the query will be
SELECT *
FROM names, num
WHERE num.o <= names.repeat
If we presume that your all_objects system object has more objects than the max repeat...
SELECT n.name
FROM names n
LEFT JOIN (Select rownum from all_objects) z
on z.rowNum < n.repeat
I just found an alternative with connect by and correlated sub-query.
select name
from names o
connect by level <= ( select repeat from names
i where i.name = o.name )
AND
prior name = name and
prior sys_guid() is not null
order by name;