MySQL:反向GROUP_CONCAT失败。怎么了?

时间:2015-12-26 07:24:55

标签: mysql

我有一张桌子"来源"列id和内容。

| ID |内容|

| 1 |消化是将食物转化为能量燃料的过程|

| 2 |在消化过程中,食物从喉咙流下来。

| 3 |消化系统的健康与生活方式有很大关系|

我想通过空间来爆炸。

这是MySQL工作台中的脚本:

CREATE PROCEDURE explode_table ()
BEGIN
DECLARE idparagraf INTEGER;
DECLARE paragraf TEXT;
DECLARE i INTEGER;
DECLARE h INTEGER;
DECLARE Frase TEXT;
DECLARE input_text TEXT;
DECLARE segmenter VARCHAR(45);
DECLARE exit_loop BOOLEAN default FALSE;
DECLARE my_cursor CURSOR FOR SELECT id, contents FROM source;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET exit_loop = TRUE;

SET h=0;
SET i=0;
SET exit_loop=FALSE;
SET segmenter=REPLACE(segmenter, '  ', ' ');
SET input_text=REPLACE(input_text, '  ', ' ');

            CREATE TEMPORARY TABLE WordList
                (
                ID INTEGER AUTO_INCREMENT NOT NULL,
                IdParagraph INTEGER,
                Words TEXT,
                PRIMARY KEY (ID)
                );


OPEN my_cursor;

RowByRow : LOOP

    FETCH  my_cursor INTO idparagraf, paragraf;


    IF exit_loop THEN
        SELECT * FROM WordList;
        CLOSE my_cursor;
        LEAVE RowByRow;
    END IF;

    REPEAT
        SET i=i+1;
            SET Frase = split_string(paragraf,' ', i);
            INSERT INTO WordList
                (ID, IdParagraph, Words)
            VALUES
                (0, idparagraf, Frase);
        UNTIL i = ComplexCount(paragraf,' ')
    END REPEAT;

SELECT * FROM WordList;

END LOOP RowByRow;

END

问题可能在于DECLARE CONTINUE HANDLER FOR NOT FOUND SET exit_loop = TRUE;或" IF exit_loop那么"或者?

我们将不胜感激。请帮忙

0 个答案:

没有答案