mysql存储过程声明错误

时间:2015-01-18 18:05:24

标签: mysql stored-procedures declare

我真的没有得到错误......

我在开始后立即声明声明。我通常做很多MS SQL,所以我不是用mysql语法练习的。请帮帮我

DELIMITER //
CREATE DEFINER=`root`@`localhost` PROCEDURE `AddEntry2`(IN `inDate` DATE, IN `inUser` INT, IN `inComment` TEXT, IN `inStart` INT, IN `inEnd` INT)
BEGIN
DECLARE commID UNSIGNED;
INSERT IGNORE INTO dimcomment (comment) values (inComment);
SELECT commID := MAX(id) 
                          FROM  dimcomment 
                          WHERE comment = inComment;

INSERT INTO factentry (FKDate, FKUser, FKComment,FKStart,FKEnd,FKAbsence)
VALUES (
        inDate,
        inUser,
        commID,
        inStart,
        inEnd,
        1
    );
END //

我得到错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED;
INSERT IGNORE INTO dimcomment (comment) values (inComment);
SELECT c' at line 3 

我将UNSIGNED更改为INT并更改了错误消息:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':= MAX(id) 
                          FROM     dimcomment 
                      ' at line 5

好像我无法通过SELECT VAR设置:= VALUE?

0 个答案:

没有答案