mysql存储过程的错误,语法不熟,找了好久没找到错误。。。
CREATEPROCEDUREupdate_pointer()begin/*done为1执行异常,停止执行*/DECLAREDoneINTDEFAULT0;DECLARE...
CREATE PROCEDURE update_pointer()begin/*done为1执行异常,停止执行*/DECLARE Done INT DEFAULT 0;DECLARE nowtime INT;DECLARE yue float;DECLARE uid int;DECLARE yqmoney float;DECLARE summoney float;DECLARE overtime INT;DECLARE hyue float;/*SET nowtime=current_time();*//* 声明游标 */DECLARE rs CURSOR FOR SELECT id,money,username,htime,overduetime FROM zhangdan WHERE paystatus!=1;/* 异常处理 */DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1;/* 打开游标 */OPEN rs;FETCH NEXT FROM rs INTO nowtime,yue,uid,yqmoney,summoney,overtime,hyue;/* 遍历数据表 */REPEATIF NOT DoneTHENSET nowtime=current_time();IF nowtime >= htimeTHENSELECT money into yue FROM pmw_member where pmw_member.username=username;SELECT id into uid FROM pmw_member where pmw_member.username=username;SET yqmoney = convert((ceil(overduetime/(24*60*60))*0.01),2);SET summoney = money + yqmoney;IF yue < summoneyTHENSET overtime = nowtime-htime;UPDATE zhangdan SET overduetime = overtime WHERE zhangdan.id = id;ELSESET hyue = yue-summoney;UPDATE pmw_member SET pmw_member.money = hyue WHERE pmw_member.username = username;UPDATE zhangdan SET paystatus = 1 WHERE zhangdan.id = id;INSERT INTO `pmw_money` (`username`, `uid`, `title`, `money`, `leixing`, `posttime`, `pid`, `hkjzrq`, `yqlx`, `payorderid`) VALUES ('username', 'uid', '还款', 'money', '支出', 'nowtime', 'pid','htime','yqmoney','goodsorderid');END IF;END IF;END IF;FETCH NEXT FROM rs INTO nowtime,yue,uid,yqmoney,summoney,overtime,hyue;UNTIL Done END REPEAT;/* 关闭游标 */CLOSE rs;end
展开
2016-05-25
展开全部
create procedure pro_getId(out userName char(20),in userId int)
begin
select Uname from user where User_id=userId;
end
--L调用存储过程
CALL proc_employee_getCount(@userName);
begin
select Uname from user where User_id=userId;
end
--L调用存储过程
CALL proc_employee_getCount(@userName);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询