CODER_V
无道loading
2017-02-15 07:39

mysql触发器 转 sqlsever触发器

10
  • mysql

怎么把这段mysql触发器 转成 sqlsever触发器的

 DROP TRIGGER IF EXISTS t_beforeinsert_on_st_pptn_r;
CREATE TRIGGER t_beforeinsert_on_st_pptn_r BEFORE INSERT
ON st_pptn_r
FOR EACH ROW
BEGIN
 CASE 
 WHEN 0<=new.DRP AND new.DRP<30 
 THEN SET new.STATUS="正常";
 WHEN 30<=new.DRP AND new.DRP<40
 THEN SET new.STATUS="报警";
 INSERT INTO st_alert_b(STCD,TM,VAL,LEVEL,STATUS) VALUES(new.STCD,new.TM,new.DRP,"II","报警");
 WHEN 40<=new.DRP AND new.DRP<=100
 THEN SET new.STATUS="报警";
 INSERT INTO st_alert_b(STCD,TM,VAL,LEVEL,STATUS) VALUES(new.STCD,new.TM,new.DRP,"I","报警");
 ELSE SET new.STATUS="异常";
 INSERT INTO st_alert_b(STCD,TM,VAL,STATUS) VALUES(new.STCD,new.TM,new.DRP,"异常");
 DELETE FROM st_pptn_r WHERE st_pptn_r.STATUS="异常";
END CASE;
END
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐