Mysql 触发器

在尝试创建一个数据库触发器以更新VIP信息并根据消费金额升级会员等级时,遇到了'Commands out of sync; you can't run this command now'的错误。触发器是在卖出信息表(sellinfor)的插入操作后更新VIP信息,如果消费总额超过50000.00,则将VIP等级升级为'金卡'。问题可能出在SQL语句的同步或执行顺序上。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

建立了一个这样的触发器:

drop trigger if exists t_vipinfor;
 create trigger t_vipinfor
  after insert on sellinfor for each row
  begin 
  #select sinum*oprice*discount sellsum from sellinfor
  # where vno =new.vno
  #then
  update vipinfor
     set totalpay=totalpay+new.sinum*new.oprice*new.discount
   where vipinfor.vno=new.vno 
  if (select totalpay from vipinfor where vno=new.vno)>=50000.00
     then
      update vipinfor
      set vgno=(select vgno from vipgrade where vgname='金卡')
      where vno=new.vno;
   
  end if;
  end    

运行后报错:
 Commands out of sync; you can't run this command now    

为什么呢?

求教!!!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值