mySql存储过程中的语法错误

时间:2013-01-29 14:11:32

标签: mysql sql

这是我的代码:

DELIMITER $$
CREATE PROCEDURE `Get_Next_Processing_Video`
(   
    OUT out_IDVideo                   INT ,
    OUT out_YoutubeIDVideo          VARCHAR(15) 
)

BEGIN

    SELECT  NP.IDVideo INTO out_IDVideo
    FROM    next_processing AS NP
  Limit 1

    UPDATE TABLE    Video AS V 
    SET     V.SchedulingFlag = TRUE
    WHERE   IDVideo = out_IDVideo

END

我不明白错误在哪里?

1 个答案:

答案 0 :(得分:1)

错误:

  • 您没有终止第一个SELECT声明
  • 您的TABLE关键字后面有一个UPDATE

固定代码:

DELIMITER $$
CREATE PROCEDURE `Get_Next_Processing_Video`
(   
    OUT out_IDVideo                   INT ,
    OUT out_YoutubeIDVideo          VARCHAR(15) 
)

BEGIN

    SELECT  NP.IDVideo INTO out_IDVideo
    FROM    next_processing AS NP
    Limit 1; 

    UPDATE  Video AS V 
    SET     V.SchedulingFlag = TRUE
    WHERE   IDVideo = out_IDVideo;

END $$
DELIMITER ;

或者,您可以使用SET为变量分配值。

    SET out_IDVideo = (SELECT   NP.IDVideo 
                        FROM    next_processing AS NP
                        Limit 1);