2010-04-14 66 views
-1

我是從T-SQL遷移到MySQL的句法和不知道如何克服由工作臺5.1.18給出這個語法錯誤:語法錯誤與MySQL Workbench和IF語句

-- -------------------------------------------------------------------------------- 
-- Routine DDL 
-- -------------------------------------------------------------------------------- 
DELIMITER // 

CREATE PROCEDURE `SysTicket`.`GetProductionLines` (aId INT, aActive INT, aResponsible VARCHAR(8000)) 
BEGIN 
    IF(aId > 0) THEN SELECT * FROM ProductionLine WHERE Id = @Id; 

    ELSE IF(aActive <> -1 AND aResponsible = '|$EMPTYARG$|') THEN SELECT * FROM ProductionLine; 

    ELSE IF(aResponsible = '|$EMPTYARG&|') THEN SELECT * FROM ProductionLine WHERE Active = aActive; 

    ELSE SELECT * FROM ProductionLine WHERE Active = aActive AND Responsible LIKE CONCAT('%', aResponsible, '%'); 

    END IF;  
END// 

它說語法錯誤提前近END(最後一行) ty。

回答

-1

想通了...... 正確的語法是:

ELSEIF 

,而不是

ELSE IF