在具有多个IF/CASE条件的SQLite UPDATE触发器中

in sqlite update trigger with multiple if/Case Conditions(在具有多个IF/CASE条件的SQLite UPDATE触发器中)
本文介绍了在具有多个IF/CASE条件的SQLite UPDATE触发器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在触发器中如何获取多个条件检查LIKE

CREATE TRIGGER record_big_order AFTER INSERT ON orders 
BEGIN 
IF new.value > 1000000 THEN 
  INSERT INTO big_orders (customer_name, salesman_id, value,Mark) 
                  VALUES (new.customer_name, new.salesman_id, new.value,'1') 
END IF; 
IF new.value > 2000000 THEN 
  INSERT INTO big_orders (customer_name, salesman_id, value,Mark) 
                  VALUES (new.customer_name, new.salesman_id, new.value,'2') 
END IF; 
IF new.value > 3000000 THEN 
  INSERT INTO big_orders (customer_name, salesman_id, value,Mark) 
                  VALUES (new.customer_name, new.salesman_id, new.value,'3')
END IF; 
END;

推荐答案

您可以尝试下面的INSERT语句-

INSERT INTO big_orders (customer_name, salesman_id, value,Mark) 
VALUES (new.customer_name, new.salesman_id, new.value,
        CASE WHEN new.value > 3000000 THEN '3'
             WHEN new.value > 2000000 THEN '2'
             WHEN new.value > 1000000 THEN '1' END) 

这篇关于在具有多个IF/CASE条件的SQLite UPDATE触发器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

FastAPI + Tortoise ORM + FastAPI Users (Python) - Relationship - Many To Many(FastAPI+Tortoise ORM+FastAPI用户(Python)-关系-多对多)
Window functions not working in pd.read_sql; Its shows error(窗口函数在pd.read_sql中不起作用;它显示错误)
(Closed) Leaflet.js: How I can Do Editing Geometry On Specific Object I Select Only?((已关闭)Leaflet.js:如何仅在我选择的特定对象上编辑几何图形?)
Android: Why is Room so slow?(Android:为什么Room这么慢?)
SQLite function to format numbers with leading zeroes?(SQLite 函数用前导零格式化数字?)
In SQL Server Management Studio 2014, the New Trigger menu option is disabled(在 SQL Server Management Studio 2014 中,新触发器菜单选项被禁用)