mysql触发器怎么调试


mysql触发器怎么调试

文章插图

mysql中调试触发器的方法
具体调试方法如下:
CREATEDEFINER=`root`@`%`TRIGGER`t_afterinsert_to_summary`AFTERINSERTON`a`FOREACHROW
begin
declarev1VARCHAR(20);
declarev2VARCHAR(20);
declaredoneintdefault0;
DECLAREmobVARCHAR(20);
DECLAREcontentVARCHAR(500);
DECLAREnode_ipVARCHAR(20);
DECLAREmobile_listCURSORFORSELECTmobileFROMcWHEREc.c=new.c1;
declarecontinuehandlerfornotFOUNDsetdone=1;/*done=true;亦可*/
insertintot(x,cc)VALUES(new.c1,'topfirest0');-------人为插入作业点
IF(new.c1=0)THEN
insertintot(x,cc)VALUES(new.c1,'firest1');-------人为插入作业点
selectbintov1frombwhereb.a=new.c1;
setv2=new.c1;
insertintot(x,cc)VALUES(new.c1,'firest2');-------人为插入作业点
SETcontent=CONCAT('abcabcabc','[',v2,']','dede',v2,'ccddddd');
insertintot(x,cc)VALUES(new.c1,'firest3');-------人为插入作业点
insertintot(x,cc)VALUES(new.c1,'firest4');-------人为插入作业点
OPENmobile_list;--将游标中的值赋值给变量,要注意sql结果列的顺序
REPEAT
FETCHmobile_listINTOmob;--while循环
ifnotdonethen
insertintot(x,cc)VALUES(new.c1,'firest5');-------人为插入作业点
INSERTINTOt(x,cc)VALUES(v2,content);
【mysql触发器怎么调试】endif;
--关闭游标
untildoneendrepeat;
CLOSEmobile_list;
ENDIF;
end;

    推荐阅读