我正在写一个程序 -
DELIMITER $$
USE `genome`$$
DROP PROCEDURE IF EXISTS `get_family`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_family`(p_h INT(10))
BEGIN
DECLARE rv,q,queue,queue_children VARCHAR(1024);
DECLARE queue_length,front_id,pos INT;
SET rv = '';
SET queue = p_h;
SET queue_length = 1;
WHILE queue_length > 0 DO
SET front_id = FORMAT(queue,0);
IF queue_length = 1 THEN
SET queue = '';
ELSE
SET pos = LOCATE(',',queue) + 1;
SET q = SUBSTR(queue,pos);
SET queue = q;
END IF;
SET queue_length = queue_length - 1;
SELECT IFNULL(qc,'') INTO queue_children
FROM (SELECT GROUP_CONCAT(id) qc
FROM folder WHERE parent = front_id) A;
IF LENGTH(queue_children) = 0 THEN
IF LENGTH(queue) = 0 THEN
SET queue_length = 0;
END IF;
ELSE
IF LENGTH(rv) = 0 THEN
SET rv = queue_children;
ELSE
SET rv = CONCAT(rv,',',queue_children);
END IF;
IF LENGTH(queue) = 0 THEN
SET queue = queue_children;
ELSE
SET queue = CONCAT(queue,',',queue_children);
END IF;
SET queue_length = LENGTH(queue) - LENGTH(REPLACE(queue,',','')) + 1;
END IF;
END WHILE;
SELECT rv FROM DUAL;
END$$
DELIMITER ;
它成功了,但是当我调用proc时,它给了我错误 -
call get_family(117);
Error Code: 1292
Truncated incorrect DOUBLE value: '118,119,120,124'
但是当我在程序中传递相同的116时,它的工作正常。 我在哪里做错了。请告诉我。
答案 0 :(得分:0)
好的,我得到了解决方案。
我只是将varchar(输出很长,我认为)类型更改为顶部的文本,现在它正常工作。