|
- BEGIN
- #定义 变量
- DECLARE a int;
- #这个用于处理游标到达最后一行的情况
- DECLARE s int default 0;
- #声明游标cursor_name(cursor_name是个多行结果集)
- DECLARE cursor_name CURSOR FOR select uid from member where shouquan_code<>'' and unix_timestamp(now())> end_time;
- #设置一个终止标记
- DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s=1;
- #打开游标
- OPEN cursor_name;
- #获取游标当前指针的记录,读取一行数据并传给变量a,b
- fetch cursor_name into a;
- #开始循环,判断是否游标已经到达了最后作为循环条件
- while s <> 1 do
- update member set shouquan_code= '' where uid = a;
- update member_field_forum set medals= '' where uid = a;
- fetch cursor_name into a;
- end while;
- #关闭游标
- CLOSE cursor_name ;
- END
复制代码
|
|