bill表机构:(订单表)
        +int id +
        +int statua+状态主键
        +date nowdate +
        +int ctobreview_id + 外键表
        
ctobreview表机构:(评价表)
        +id
        +
billitem 是定单项表shop是店铺product是产品表create trigger mytrigger after update on bill 
for each row
begin
     DECLARE billId,reivewID,shopID,productID int ;
     if(bill.status == 2 && bill.ctobreview_id == NULL && datediff(bill.nowdate,now())>15)
     begin
          set billId = bill.id;
         --select id into billId from bill where status = 2 and ctobreview = null;
         SELECT product_id into productID from billitem where bill_id = billId;
         select shop_id into shopID from product where shop_id = productID;
         insert into ctobReview values(2,null,null,10,10,10,10,shopID);
         -- select @reviewID from inserted;
         select last_insert_id();
         update bill set ctobreview_id = reviewID where id = billId; 
     end
end
大家帮我改下个这个触发器  我对mysql不是很了解,谢谢啦

解决方案 »

  1.   

    本帖最后由 yueliangdao0608 于 2008-04-12 13:56:04 编辑
      

  2.   


    不要需要返回  return null可以吗
      

  3.   


    如果不需要返回值,return null 可以吗
      

  4.   

    改一下就可以了。
        if(new.status == 2 && new.ctobreview_id == NULL && datediff(new.nowdate,now())>15)
         begin
              set billId = new.id; 
      

  5.   


    改好之后为什么一直这样啊 难道还是版本问题
    "check the manual that corresponds to your 
    mysql server version for the right syntax to use near"
      

  6.   

    你有没有改delimiter ?[align=center]====  ====
    [/align]
      

  7.   

    以下摘自 MySQL 5.1 Reference Manual
    [align=center]====  ====
    [/align]
      

  8.   


    我刚刚接触mysql 不知道什么是delimiter  就不曾该过!
      

  9.   


    [align=center]====  ====
    [/align]
      

  10.   


    我用上面的代码试 错误提示还是那样
    "check the manual that corresponds to your  
    mysql server version for the right syntax to use near delimiter"