update_curr
时间: 2023-11-08 21:06:59 浏览: 227
update_curr()是Linux2.6的CFS调度器中的一个函数,它被系统定时器周期性调用,用于计算当前进程的执行时间,并将其存放在变量delta_exec中。然后,它将运行时间传递给__update_curr(),__update_curr()根据当前进程总数对运行时间进行加权计算,最终将计算结果与当前运行进程的vruntime相加,并将结果赋给vruntime。在基于pelt的负载计算中,dequeue_entity和enqueue_entity都调用了update_curr函数进行负载的更新。
相关问题
请将这个存储过程修改为触发器,当其余四个表插入新数据时,t_pcm_prod_own能够修改更新数据 CREATE DEFINER=root@% PROCEDURE test03() BEGIN -- 是否持有活期 IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_CURR)) THEN UPDATE T_PCM_PROD_OWN SET IS_DEP = '1' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_CURR); ELSE UPDATE T_PCM_PROD_OWN SET IS_DEP = '0' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_CURR); END IF; -- 是否持有定期 IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_FIXED)) THEN UPDATE T_PCM_PROD_OWN SET IS_FIXED_DEP = '1' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_FIXED); ELSE UPDATE T_PCM_PROD_OWN SET IS_FIXED_DEP = '0' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_DEP_FIXED); END IF; -- 是否持有贷款 IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_LOAN)) THEN UPDATE T_PCM_PROD_OWN SET IS_LOAN = '1' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_LOAN); ELSE UPDATE T_PCM_PROD_OWN SET IS_LOAN = '0' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_LOAN); END IF; -- 是否持有理财 IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_WEALTH)) THEN UPDATE T_PCM_PROD_OWN SET IS_WEALTH = '1' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_WEALTH); ELSE UPDATE T_PCM_PROD_OWN SET IS_WEALTH = '0' WHERE CUST_ID IN (SELECT CUST_ID FROM T_PCM_WEALTH); END IF; INSERT INTO T_PCM_PROD_OWN SELECT REPLACE(UUID(),'-','') ,T_PCM_CUST.CUST_ID ,T_PCM_CUST.LAW_ORG_ID ,T_PCM_CUST.ECIF_CUST_ID ,T_PCM_PROD_OWN.IS_DEP ,T_PCM_PROD_OWN.IS_FIXED_DEP ,T_PCM_PROD_OWN.IS_LOAN ,T_PCM_PROD_OWN.IS_WEALTH ,T_PCM_DEP_CURR.CURRENT_BAL ,T_PCM_DEP_FIXED.BAL ,T_PCM_LOAN.LOAN_MON ,T_PCM_WEALTH.CURRENT_BAL FROM T_PCM_CUST LEFT JOIN T_PCM_DEP_CURR ON T_PCM_CUST.CUST_ID = T_PCM_DEP_CURR.CUST_ID LEFT JOIN T_PCM_DEP_FIXED ON T_PCM_CUST.CUST_ID = T_PCM_DEP_FIXED.CUST_ID LEFT JOIN T_PCM_LOAN ON T_PCM_CUST.CUST_ID = T_PCM_LOAN.CUST_ID LEFT JOIN T_PCM_WEALTH ON T_PCM_CUST.CUST_ID = T_PCM_WEALTH.CUST_ID LEFT JOIN T_PCM_PROD_OWN ON T_PCM_CUST.CUST_ID = T_PCM_PROD_OWN.CUST_ID; END
您好!根据您的要求,将存储过程修改为触发器,当其余四个表插入新数据时,t_pcm_prod_own将能够修改更新数据。以下是修改后的触发器代码:
```mysql
CREATE DEFINER=root@% TRIGGER trg_test03
AFTER INSERT ON T_PCM_DEP_CURR
FOR EACH ROW
BEGIN
-- 是否持有活期
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_DEP = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_DEP = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END;
CREATE DEFINER=root@% TRIGGER trg_test03_2
AFTER INSERT ON T_PCM_DEP_FIXED
FOR EACH ROW
BEGIN
-- 是否持有定期
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_FIXED_DEP = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_FIXED_DEP = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END;
CREATE DEFINER=root@% TRIGGER trg_test03_3
AFTER INSERT ON T_PCM_LOAN
FOR EACH ROW
BEGIN
-- 是否持有贷款
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_LOAN = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_LOAN = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END;
CREATE DEFINER=root@% TRIGGER trg_test03_4
AFTER INSERT ON T_PCM_WEALTH
FOR EACH ROW
BEGIN
-- 是否持有理财
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_WEALTH = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_WEALTH = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END;
```
请注意,每个表都有一个单独的触发器,以确保在插入新数据时更新相应的列。触发器将根据新插入的数据的CUST_ID值来更新t_pcm_prod_own表中的相关列。
这段代码为什么会报错> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '% TRIGGER trg_test03 AFTER INSERT ON T_PCM_DEP_CURR FOR EACH ROW BEGIN
抱歉,我之前的回答有误。MySQL中不能直接在phpMyAdmin或MySQL命令行中创建触发器,只能通过执行SQL脚本或使用数据库管理工具来创建触发器。
请将以下代码保存为一个.sql文件,然后通过执行该文件来创建触发器:
```mysql
DELIMITER //
CREATE TRIGGER trg_test03
AFTER INSERT ON T_PCM_DEP_CURR
FOR EACH ROW
BEGIN
-- 是否持有活期
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_DEP = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_DEP = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END //
CREATE TRIGGER trg_test03_2
AFTER INSERT ON T_PCM_DEP_FIXED
FOR EACH ROW
BEGIN
-- 是否持有定期
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_FIXED_DEP = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_FIXED_DEP = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END //
CREATE TRIGGER trg_test03_3
AFTER INSERT ON T_PCM_LOAN
FOR EACH ROW
BEGIN
-- 是否持有贷款
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_LOAN = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_LOAN = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END //
CREATE TRIGGER trg_test03_4
AFTER INSERT ON T_PCM_WEALTH
FOR EACH ROW
BEGIN
-- 是否持有理财
IF EXISTS(SELECT CUST_ID FROM T_PCM_PROD_OWN WHERE CUST_ID = NEW.CUST_ID) THEN
UPDATE T_PCM_PROD_OWN
SET IS_WEALTH = '1'
WHERE CUST_ID = NEW.CUST_ID;
ELSE
UPDATE T_PCM_PROD_OWN
SET IS_WEALTH = '0'
WHERE CUST_ID = NEW.CUST_ID;
END IF;
END //
DELIMITER ;
```
将上述代码保存为文件(例如:trigger.sql),然后通过执行该文件来创建触发器:
```
source /path/to/trigger.sql;
```
请确保将`/path/to/trigger.sql`替换为实际的文件路径。执行成功后,将会创建这些触发器。
阅读全文