-- Examples from Section 3.10
-- Note that these modify the CAP database!

-- Example 3.10.1

     insert into orders (ordno, month, cid, aid, pid)
          values (1107, 'aug', 'c006', 'a04', 'p01');

     insert into orders (ordno, month, cid, aid, pid, qty, dollars)
          values (1107, 'aug', 'c006', 'a04', 'p01', null, null);

-- Example 3.10.2

     create table swcusts (cid char(4) not null, cname varchar(13), 
          city varchar(20), discnt real);

     insert into swcusts 
          select * from customers
               where city in ('Dallas', 'Austin');

-- Example 3.10.3

     update agents set percent = 1.1 * percent where city = 'New York';

-- Example 3.10.4

     update customers set discnt = 1.1 * discnt where cid in
          (select cid from orders group by cid having sum(dollars) > 1000);

-- Example 3.10.5

    update swcusts set discnt = (select discnt from customers where cid = swcusts.cid);

-- Example 3.10.6

     delete from agents where city = 'New York';

-- Example 3.10.7

     delete from agents where aid in
          (select aid from orders group by aid having sum(dollars) < 600);

