代码如下:
BEGIN DECLARE tmpName VARCHAR(20) DEFAULT "" ; DECLARE allName VARCHAR(255) DEFAULT "" ; DECLARE user_info VARCHAR(255) DEFAULT ""; /*开启游标*/ DECLARE cur1 CURSOR FOR SELECT id FROM test; /*游标异常后捕捉*/ DECLARE CONTINUE HANDLER FOR SQLSTATE "02000" SET tmpname = NULL; /*打开游标*/ OPEN cur1; /*游标向下一步*/ FETCH cur1 INTO tmpname; /*循环游标*/ WHILE (tmpName IS NOT NULL ) DO set user_info = (SELECT uid FROM test2 where uid = tmpName ); if tmpName = user_info then /*得到uid*/ UPDATE test2 SET id=1 WHERE id = 1; /*就是这一句没有执行,但是进入了 if 条件里面*/ SET tmpName = CONCAT(tmpName,":"); /*这里有执行*/ SET allName = CONCAT(allName,tmpname); end IF; /*游标再向下走,一直循环*/ FETCH cur1 INTO tmpName; END WHILE; /*结束循环体*/ /*关闭游标*/ CLOSE cur1; SELECT allName ; END
解决方案
20
LZ是怎么样断定这一句没有执行的呢?