Q1)
create or replace function f1
return number
is
cnt number;
begin
select count(route_no) into cnt from Route
where no_of_station >10;
return cnt;
end;
select f1 from dual;
Q2)
declare
cursor c1 is select distinct source from Route;
cursor c2 (rt Route.source%type) is select b.bus_no , b.capacity , b.depot_name
from Route r , Bus b where r.route_no=b.route_no and r.source = rt;
begin
for a in c1 loop
dbms_output.put_line(a.source);
for c in c2 (a.source) loop
dbms_output.put_line(c.bus_no||' '||c.capacity||' '||c.depot_name);
end loop;
end loop;
end;