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!

Print FOR LOOP Iteration sequence value

Jeevanantham VSep 5 2019 — edited Sep 5 2019

Sample code:

set serveroutput on;

declare

begin

for p in (select 123 id from dual union select 324 from dual)

loop

dbms_output.put_line('value  ' || p || 'is:' || p.id);

end loop;

end;

/

Expected output:

Value 1 is: 123

Value 2 is: 324.

Is there any other way apart from increasing local defined variable value, one by one inside the loop for each iteration. ( Do not use this logic :  for p in (query) loop i := i+1; print value , end loop). I am expecting some other mechanism

Comments
Post Details
Added on Sep 5 2019
4 comments
5,917 views