Q1)create or replace function fun1(mno in number)
return number
is
total number;
begin
select count(d.d_no) into total from Drug d,Med_s ms,D_M dm
where d.d_no=dm.d_no and ms.m_no=dm.m_no
and dm.m_no=mno;
return total;
end;
Q2)
declare
cursor c1 is select quantity from D_M;
cursor c2 (qty D_M.quantity%type) is select d.* from
Drug d,Med_s ms,D_M dm
where d.d_no=dm.d_no and ms.m_no=dm.m_no and quantity=qty;
begin
for x in c1 loop
dbms_output.put_line(x.quantity);
for y in c2 (x.quantity) loop
dbms_output.put_line(y.d_no||' '||y.d_name||' '||y.company||' '||y.price);
end loop;
end loop;
end;