Q1)
create or replace procedure p1
as
cursor c1 is select c_name from Company;
cursor c2(cname in Company.c_name%type) is select distinct p_name from Company c,Person p,CO_P cp
where c.c_no=cp.c_no and p.p_no=cp.p_no and c_name=cname;
r1 c1%rowtype;
r2 c2%rowtype;
begin
open c1;
loop
fetch c1 into r1;
exit when c1%notfound;
dbms_output.put_line(r1.c_name);
open c2(r1.c_name);
loop
fetch c2 into r2;
exit when c2%notfound;
dbms_output.put_line(r2.p_name);
end loop;
close c2;
end loop;
close c1;
end;
declare
begin
p1;
end;
Q2)
create or replace trigger t10
before insert or update on Company
for each row
begin
if (:new.c_share_value<10) then
raise_application_error(-2010,'share of value should be greater than 10');
end if;
end;