MSQL存储过程
2016-06-08 19:13
246 查看
BEGIN
declare _userName varchar(12); -- 用户名
declare _chinese int ; -- 语文
declare _math int ; -- 数学
declare done int;
-- 定义游标
DECLARE rs_cursor CURSOR FOR SELECT username,chinese,math from userInfo where datediff(createDate, date_day)=0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
-- 获取昨天的日期
if date_day is null then
set date_day = date_add(now(),interval -1 day);
end if;
open rs_cursor;
cursor_loop:loop
FETCH rs_cursor into _userName, _chinese, _math; -- 取数据
if done=1 then
leave cursor_loop;
end if;
-- 更新表
update infoSum set total=_chinese+_math where UserName=_userName;
end loop cursor_loop;
close rs_cursor;
END
declare _userName varchar(12); -- 用户名
declare _chinese int ; -- 语文
declare _math int ; -- 数学
declare done int;
-- 定义游标
DECLARE rs_cursor CURSOR FOR SELECT username,chinese,math from userInfo where datediff(createDate, date_day)=0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
-- 获取昨天的日期
if date_day is null then
set date_day = date_add(now(),interval -1 day);
end if;
open rs_cursor;
cursor_loop:loop
FETCH rs_cursor into _userName, _chinese, _math; -- 取数据
if done=1 then
leave cursor_loop;
end if;
-- 更新表
update infoSum set total=_chinese+_math where UserName=_userName;
end loop cursor_loop;
close rs_cursor;
END
相关文章推荐
- MyEclipse Web Project转Eclipse Dynamic Web Project
- 微软Word 2007数学插件 Microsoft Math 提供下载
- 关于C# Math 处理奇进偶不进的实现代码
- MyEclipse连接Mysql数据库的方法(一)
- MyEclipse常用配置图文教程
- JavaScript Math 对象常用方法总结
- JavaScript中的Math.SQRT1_2属性使用简介
- JavaScript Math.ceil() 函数使用介绍
- 与Math.pow 相反的函数使用介绍
- JavaScript中使用指数方法Math.exp()的简介
- JavaScript使用Math.Min返回两个数中较小数的方法
- MyEclipse连接MySQL数据库报错解决办法
- Ajax获取页面被缓存的解决方法
- 在myeclipse中如何加入jquery代码提示功能
- MyEclipse 6.0.1 6.0GA 6.0M1 5.5GA 5.1.1GA 注册码及高速下载地址
- JavaScript高级程序设计 阅读笔记(十二) js内置对象Math
- javascript在myeclipse中报错的解决方法
- JavaScript中Math对象使用说明
- javascript对象之内置对象Math使用方法
- eclipse3.2.2 + MyEclipse5.5 + Tomcat5.5.27 配置数据库连接池