首页 > 编程知识 正文

mysql数据库函数,oracle存储过程语法

时间:2023-05-03 16:22:20 阅读:168257 作者:3508

如何编写MySQL存储过程和使用“当前”

2008-03-11

eNetCiweek

本文介绍了与使用Cursor相关的MySQL存储过程。 例如以下所示。

创建进程` justifygroupnum ` (

非细节

SQL SECURITY DEFINER

COMMENT ' '

比根

/* how torun : calljustifygroupnum () ) /

DECLARE p_group_id int;

declare p_num int;

取消停止标志int;

DECLARE cursor_name CURSOR

FOR select c_group_id,count(* ) as num

from `t_group_member `

wherec _ validin (3,4 ) ) ) ) ) ) ) ) wherec _ validin (3,4 ) ) ) ) ) wherec _ validin (3,4 ) ) ) ) ) ) ) ) wher ) ) ) wher。

group by c_group_id;

declarecontinuehandlerfornotfoundsetstopflag=1;

OPEN cursor_name;

REPEAT

FETCH cursor_name INTO p_group_id,p_num;

比根

updatet _ group infos etc _ member _ number=p _ numwherec _ group _ id=p _ group _ id;

结束;

UNTIL stopFlag=1

结束报告;

CLOSE cursor_name;

结束;

总结:

1、注意光标countinuehandler的设置: declarecontinuehandlerfornotfoundsetstopflag=1;

2、请注意使用REPEAT和UTILE [停止条件] END REPEAT。 不这样做的话就不会循环;

3、如何运行,输入运行: call justifyGroupNum () ) )。

如果对这篇文章或本站有意见,请在下面提出。 谢谢你。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。