mysql:
/*更新用户禁用清空用户信息OPENID*/ DELIMITER $$ CREATE /*!50017 DEFINER = 'root'@'%' */ TRIGGER `TR_USERS_UPDATE` AFTER UPDATE ON `USERS` FOR EACH ROW BEGIN DECLARE VAR_ACTIVE VARCHAR (2) ; SET VAR_ACTIVE = '' ; SET VAR_ACTIVE = new.is_active; IF VAR_ACTIVE = 'N' THEN UPDATE USERS_INFO SET OPENID = NULL WHERE ID = new.users_info_id; END IF; END ; $$ DELIMITER ;
oracle:
-- 更新用户禁用清空用户信息OPENID CREATE OR REPLACE TRIGGER TR_USERS_UPDATE AFTER UPDATE ON USERS REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE VAR_ACTIVE VARCHAR2(2); BEGIN VAR_ACTIVE := :NEW.IS_ACTIVE; IF VAR_ACTIVE = 'N' THEN UPDATE USERS_INFO SET OPENID = NULL WHERE ID = :NEW.USERS_INFO_ID; END IF; EXCEPTION WHEN OTHERS THEN RAISE; END TR_USERS_UPDATE;