mysql函数、事件示例

本文介绍了一个自定义函数`noModify`,用于在特定条件下更新用户评分和系统状态。通过调用此函数,系统可以执行一系列操作,包括从数据库中检索审计ID和计数器ID,然后根据审计ID更新用户评分、状态和记录评分日志。此外,该函数还负责删除不再使用的计数器ID,确保系统资源的有效管理和优化。

函数名:noModify

BEGIN 



declare auditP int(10);
declare scoreP double(20,2);
declare sid int(10) ; 
declare cid int(10); 
SET sid=( SELECT auditId FROM a_countdown where isuse='1' and  type='4'  and  endtime<NOW() limit 1);
SET cid=( SELECT id FROM a_countdown where isuse='1' and  type='4'  and  endtime<NOW() limit 1 );
if sid is not null and sid<>0 then
set auditP=(select auditObject from audit_process where id=sid);
set scoreP=(select score from audit_process where id=sid);
insert into jf_userscorelog (userid,auditid,score,scorenameid,scoringtime,scorereason,scoreruleid) 
values(auditP,sid,scoreP,11,SYSDATE(),'对员工工作绩效考核的评分',33); 
update audit_process set state=4,isrechange=0 where id = sid;
DELETE from  a_countdown  where id=cid; 
end if;

END


说明: declare是声明一个参数

可以在计划事件中执行函数 noModify ,如:

BEGIN
call noModify();
END

配置计划示例


也可以在事件中直接写,如:

BEGIN
delete from t_task_affix where length(taskid)>32;
delete from bs_backcashplanissue where length(planId)>32;
delete from f_feedback where length(feedbackid)>32;
END


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值