本文介紹了在具有多個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觸發器中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,