Preview:
DECLARE

CURSOR C1(R NUMBER) IS SELECT * FROM SAILORS WHERE RATING=R;

I INTEGER;

BEGIN

FOR I IN 1..10 LOOP

DBMS_OUTPUT.PUT_LINE('SAILORS WITH RATING '|| I || ' ARE');

DBMS_OUTPUT.PUT_LINE('SID NAME AGE');

FOR Z IN C1(I) LOOP

/* It‘s not compulsory to define variable using rowtype for simple cursor as well as for update cursor */

DBMS_OUTPUT.PUT_LINE(Z.SID ||' ' ||Z.SNAME ||' '||Z.AGE);

END LOOP;

END LOOP;

END;

/





 create table sailors (sid integer,sname varchar2(30),rating integer,age real,primary key (sid));

 insert into sailors values(22, 'dustin',7,45.0);

 insert into sailors values(31, 'lubber',8,55.5);

 insert into sailors values(58, 'rusty', 10, 35.0);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter