Dbms
Mon Apr 01 2024 04:38:06 GMT+0000 (Coordinated Universal Time)
Saved by
@V07
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);
content_copyCOPY
Comments