(I) #1 select aname from agents where percent > (select max(percent) from agents where city='Dallas') and aid not in (select distinct aid from customers c, orders o where city='Dallas' and c.cid=o.cid); #2 select cid from customers c where not exists (select pid from orders o1 where aid='a05' and not exists (select * from orders o2 where o2.cid=c.cid and o2.pid=o1.pid )); #3 select aid, aname from agents a where not exists (select pid from orders o1 where cid='c002' and not exists (select * from agents a2, orders o2 where o2.aid=a.aid and o1.pid=o2.pid and a.percent > a2.percent)); (III) #1 exec sql begin declare section; char cust_id[5], agent_id[4], prod_id[4]; int ord_no, ord_qty, start_ordno, prod_qty; exec sql end declare section; #2 exec sql declare ordc cursor for select ordno, cid, aid, o.pid, qty, quantity from orders o, products p where ordno >= :start_ordno and o.pid = p.pid order by pid for update of quantity; #3 exec sql whenever not found goto clcurs; exec sql open ordc; while( sqlca.sqlcode==0 ){ exec sql fetch ordc into :ord_no, :cust_id, :agent_id, :prod_id, :ord_qty, prod_qty; if( ord_qty <= prod_qty ) exec sql update products set quantity=(:prod_qty-:ord_qty) where current of ordc; esle exec sql insert into back_orders values(ord_no, cust_id, agent_id, prod_id, ord_qty); } clsurs: exec sql close ordc; exec sql whenever not found continue;