上述就是数据库技术:MySQL 存储过程和Cursor的使用方法分享的全部内容,如果对大家有所用处且需要了解更多关于mysql数据库学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)! 示例如下:
代码如下:
CREATEPROCEDURE`justifyGroupNum`()
NOTDETERMINISTIC
SQLSECURITYDEFINER
COMMENT”
BEGIN
/*howtorun:calljustifyGroupNum()*/
DECLAREp_group_idint;
declarep_numint;
declarestopFlagint;
DECLAREcursor_nameCURSOR
FORselectc_group_id,count(*)asnum
from`t_group_member`
wherec_validin(3,4)
groupbyc_group_id;
DECLARECONTINUEHANDLERFORNOTFOUNDsetstopFlag=1;
OPENcursor_name;
REPEAT
FETCHcursor_nameINTOp_group_id,p_num;
begin
updatet_groupinfosetc_member_number=p_numwherec_group_id=p_group_id;
end;
UNTILstopFlag=1
ENDREPEAT;
CLOSEcursor_name;
END;
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/909913.html