CREATE PROCEDURE createChildLst (IN rootId INT,IN nDepth INT) BEGIN DECLARE done INT DEFAULT 0; DECLARE b INT; DECLARE cur1 CURSOR FOR SELECT id from treeNodes where pid=rootId; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
insert into tmpLst values (null,rootId,nDepth); OPEN cur1; FETCH cur1 INTO b; WHILE done=0 DO CALL createChildLst(b,nDepth+1); FETCH cur1 INTO b; END WHILE;
SELECT * from alarms where id in (select resource_id from res_products where product=22) 这个语句在mysql中为什么不能执行?我的mysql数据库是5.0.27版本的! 如果实在不行那么该用个什么语句代替效率更高呢 ......
sp 程序 delimiter // create procedure ma() begin declare i int default 0; while i<11 do set i=i+1; select i; end while; end // delimiter ; 1+2+...+9+10 为什么这个程序无法实现累加效果 / ......