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!

PLSQL (FOR LOOP) with UNION

734369May 16 2010 — edited May 17 2010
I have a FOR Loop on a complex query with UNION ALL.

When I run the query below, I get results in the DBMS_OUTPUT from the query in underline, but I get not results from the the other query formed with the UNION ALL.

I cannot explain its behaviour. maybe I am doing something wrong. Is there a right way of doing this:


FOR ROWDET IN (SELECT C1,C2, C3, C4 ,C5 from (
SELECT C1, C2, C3,C4,C5 from TABLE A
UNION ALL
SELECT C1, C2, C3, C4, Test OVER (PARTITION BY TestCol order by Total desc) C5 from (
SELECT C1 C2, C3, C4 ,Test, TestCol,Total from TABLE B
)
);
LOOP
v_print_row := '<tr>';
v_print_row := v_print_row || '<td class=xl25>'|| ROWDET.C1||ROWDET.C2 || '</td>'||chr(10);
v_print_row := v_print_row||'</tr>';
DBMS_OUTPUT.PUT_LINE (v_print_row);
END LOOP;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 14 2010
Added on May 16 2010
2 comments
3,151 views