无道loading 2017-02-15 07:39 采纳率: 66.7%
浏览 976

mysql触发器 转 sqlsever触发器

怎么把这段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条回答 默认 最新

  • baipiang 2017-02-15 13:17
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求效果比较好的遥感影像匹配的c++代码
  • ¥15 博主,你好,我下载了你的智能网联汽车辅助驾驶安全信息检测系统,现在不会运行,可以教我吗,
  • ¥15 怎么在excle输入下列公式
  • ¥15 Arduino,利用modbus的RS485协议,进行对外置的温湿度传感器进行数据读取
  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题