求救。mysql存储过程如何中途退出

coolpig379 2015-02-02 04:24:49
CREATE DEFINER=`probe`@`%` PROCEDURE `RecommentGoldRewards`(
RunTime datetime
)
Label:BEGIN

IF EXISTS (SELECT * FROM iportal_wx.runinglog
WHERE BeginTime=RunTime
AND ProcedureName='RecommentGoldRewards'
AND TableName='register_details'
AND IsOK='Y') THEN LEAVE Label;
END IF;

DECLARE RowCount float;

DROP TEMPORARY TABLE IF EXISTS temp.RecommentGoldRewards;

CREATE TEMPORARY TABLE temp.RecommentGoldRewards(
user_phone bigint(20) null,
gold_number int(10) null,
title varchar(255) null,
user_action varchar(255) null);

Call SaveRunningLog ('推荐次日','程序开始','RecommentGoldRewards',NULL,NULL,'Y');

insert into temp.RecommentGoldRewards
select A.Recom_phone,20,'推荐次日','Recommend'
from iportal_wx.recom_user as A,iportal_wx.register_details as B
where A.ctime>ADDDATE(CURRENT_DATE(),-2)
and A.ctime<ADDDATE(CURRENT_DATE(),-1)
and A.user_phone = B.user_phone
and B.spare_two='每日签到' and B.ctime>ADDDATE(CURRENT_DATE(),-1)
and B.ctime<CURRENT_DATE()
group by B.user_phone;

/*金豆奖励*/
start transaction;

insert into iportal_wx.register_details(user_phone,user_action,gold_number,ctime,spare_two)
select user_phone,user_action,gold_number,now(),title
from temp.RecommentGoldRewards;

update iportal_wx.register,temp.RecommentGoldRewards
set iportal_wx.register.gold_number=iportal_wx.register.gold_number+temp.RecommentGoldRewards.gold_number
where iportal_wx.register.user_phone=temp.RecommentGoldRewards.user_phone;

commit;

set RowCount= ROW_COUNT();
Call SaveRunningLog ('推荐次日','程序结束','RecommentGoldRewards',register, RowCount,'Y');

set RowCount= FOUND_ROWS();
Call SaveRunningLog ('推荐次日','程序结束','RecommentGoldRewards',register_details, RowCount,'Y');

END
...全文
693 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolpig379 2015-02-02
  • 打赏
  • 举报
回复
在END IF那里一直报错!

2,209

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧