为什么没有到达ELSEIF?

时间:2016-12-22 12:26:24

标签: mysql redmine

我准备了一个更新之前的触发器,我在其中编码了层次关系:

CREATE DEFINER=`%`@`%` TRIGGER setToClosed
    BEFORE UPDATE ON issues
    FOR EACH ROW 
BEGIN
    declare project_id1 int;
    set @project_id1 = (select id from projects where name = 'XXX');
    IF (new.done_ratio=100) THEN
        IF (new.project_id =  @project_id1) THEN
            SET new.status_id=4;
        ELSEIF new.project_id in (
                        select  id
                        from    (select * from projects) projects_sorted,
                                (select @pv := @project_id1) initialisation
                        where   find_in_set(parent_id, @pv) > 0
                        and     @pv := concat(@pv, ',', id)) THEN
            SET new.status_id=4;

        ELSE
            SET new.status_id=5;
        END IF;
    END IF;

END

我想问为什么ELSEIF未达到?我已经测试了来自ELSEIF ant的独立查询,它返回了id列表。

status_id查询中ELSEIF出现的行更改后,触发器会进入ELSE

我该怎么办?

0 个答案:

没有答案