I am looking for a possibility to run an (Oracle) SQL without querying an actual table. Here I found a tip with the DUAL table. Thats pretty good. But I'm looking for a short solution to select MULTIPLE rows from "nowhere". Is that possible? Here is the shortest query I can think of, which does what I need:
Select 1, 'foo' FROM DUAL union
Select 2, 'bar' FROM DUAL union
Select 3, 'more stuff' FROM DUAL
But if I want to have more rows in my result, it gets pretty unhandy. Is there a shorter way? Something like
Select 1, 'foo'; 2, 'bar'; 3, 'more stuff' from dual
or
Select * from (1, 'foo') union (2, 'bar') union (3, 'more stuff')
I know, that doesn't work, but do you have an idea? Is there an easy way to transpose a queries' result? Something like:
Select transposed (1, 'foo', 2, 'bar', 3, 'more stuff') from dual
I want to keep the amount "overhead-characters" at the lowest.
You can use connect by level
to generate more records - something like:
select level, decode(level, 1,'foo', 2,'bar', 3,'more stuff')
from dual connect by level <= 3