本文介绍了在具有多个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触发器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!