1. book(id, name, isbn, author, publishing_comy, publish_time, edition_orders, print_time, book_classify, word_count, page_count, package, price, discount, synopsis, editor_commend, catalog, media_comment, state);//state 表示是否有存货
2. music(id, name, singer, publisher, emission_dealer, dish_number, medium, music_name, synopsis, media_comment, price, discount, state);
3. film(id, name, director, main_actor, package_type, dub, film_type, time, caption, screen_proportion, music_type, publisher, price, state);
4. software(id, name, isbn, publish_time, maker, dish_number, emission_dealer, dub, language, medium, synopsis, system_requre, price, discount, state);
5. game(id, name, isbn, publish_time, maker, dish_number, emission_dealer, dub, medium, syetem_requre, synopsis, price, discount, state);
6. paysum(order_id, nickname, summoney);
7. booktype(typeid, typename, fatherid);
8. customer(nickname, password, caddress, birthdate, interest, blog_address, telephone, email, gender, rank);
9. supplier(supplier_id, supplier_name, address, telephone, linkman, email);
10. warehouse(wid, address, telephone, wamount);
11. supplierdetail(supplier_id, goods_id, goods_price)//存储供货商所提供商品的种类 
12. orders(order_id, goods_id, orderdate, ordersum, payment_style, orderstate, goods_state, outdate);//订单表管理员 goods_state 是否有存货,orderstate 是否发货
13. stock(wid, goods_id, stockamount);
14. buygoods(buygoodsid, goods_id, buydate, supplier_id, goods_price, buyman, buyamount);//进货
15. speaking(goods_id, nickname, text, speakingtime);//评论表存储顾客对商品的评论信息
16. manager(id, name, password, auth, telephone, address)
求教更新stock表时如果存量为零 则设置相应的商品(或者book、music、film、software、game)的state属性为'N'
马上就要交的大作业,哪位高人帮帮我吧,万分感谢~~~~~~~~~~~~

解决方案 »

  1.   

    简单弄了下,未测试:create or replace trigger tgname
    after insert or update on stock
    for each row
    begin
    if :new.stockamount = 0 then
    update orders set goods_state='N' where goods_id=:new.goods_id;
    if SQL%NOTFOUND then
    null;
    end if;
    update book set state ='N' where id=:new.goods_id;
    if SQL%NOTFOUND then
    null;
    end if;
    --下面照抄。
    end if;
    end; 
      

  2.   

    create or replace trigger t_num   after update or insert on  stock for each row
    begin
    if :new.stockamount=0 then
    update book set state='N'  where state<> 'N' and id=:new.goods_id ;
    update music set state='N'  where state<> 'N' and id=:new.goods_id ;
    update film set state='N'  where state<> 'N' and id=:new.goods_id ;
    update software set state='N'  where state<> 'N' and id=:new.goods_id ;
    update game set state='N'  where state<> 'N' and id=:new.goods_id ;
    end if;
    end;
      

  3.   

    create or replace trigger TRIGNAME
    after update on stock
    for each row
    when (stockamount=0)
    begin
    update .. set ..='N' where ..=:new.goodsid;
    update .. set ..='N' where ..=:new.goodsid;
    .....
    end;