numeric for loop [message #620874] |
Wed, 06 August 2014 14:04 |
tuckersuz
Messages: 26 Registered: July 2009
|
Junior Member |
|
|
Hello:
I need to create a numeric for loop, with only 10 iterations, and it needs to show results in a dbms_output.put_line.
The values are retrieved from a query, and I need to show 5 results from a first query, and the other 5 from the same query, but with different filters. first query: select year, semester, type from table a, table b, where a.id = b.id, and year = '2011, semester = 'SPRING', and type = 1. The second query: select year, semester, type from table a, table b, where a.id = b.id, and year = '2012, semester = 'FALL', and type = 3. I think I need to have a constant for the loop, but I'm not sure how to do this. Any help is appreciated.
Thanks!
The desired output:
2011/SPRING/1
2011/SPRING/1
2011/SPRING/1
2011/SPRING/1
2011/SPRING/1
2012/FALL/3
2012/FALL/3
2012/FALL/3
2012/FALL/3
2012/FALL/3
|
|
|
Re: numeric for loop [message #620876 is a reply to message #620874] |
Wed, 06 August 2014 14:22 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
You don't need PL/SQL. Just use plain SQL.
Sql_query_1
UNION ALL
Sql_query_2
To limit the number of rows returned, use ROWNUM.
I insist, please post what you have tried so far and follow guidelines. Learn how to use code tags to post.
[Updated on: Wed, 06 August 2014 14:23] Report message to a moderator
|
|
|
|
|