douqi0090
douqi0090
2017-08-03 14:12

我的Mysql创建过程中出错的原因是什么

已采纳

I can't understand what is the problem of my query in Mysql. I will write my query here.

CREATE PROCEDURE PR_INSERT_DATA (
                IN prCode INT,
                IN prName VARCHAR(250),
                IN prAuthor varchar(250),
                IN prCategory varchar(250),
                IN prMaterial varchar(250),
                IN prPrice varchar(7),
                IN prDescription varchar(1000),
                IN prComment varchar(500))
BEGIN
    INSERT INTO `product`(`CODE`,`NAME`,`AUTHOR`, `CATEGORY`, `MATERIAL`, `PRICE`, `DESCRIPTION`, `COMMENT`) 
    VALUES (`prCode`
            ,`prName`
            ,`prAuthor`
            ,`prCategory`
            ,`prMaterial`
            ,`prPrice`
            ,`prDescription`
            ,`prComment`)

It gaves me this error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 19

Here is the structure of the Table.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanlv5084 duanlv5084 4年前

    You need to change the standard delimiter from ';' to another. The reason for that is because we want to pass the stored procedure to the server as a whole rather than let MySQL interpret each statement at a time.

    DELIMITER //
    CREATE PROCEDURE PR_INSERT_DATA (
                    IN prCode INT,
                    IN prName VARCHAR(250),
                    IN prAuthor varchar(250),
                    IN prCategory varchar(250),
                    IN prMaterial varchar(250),
                    IN prPrice varchar(7),
                    IN prDescription varchar(1000),
                    IN prComment varchar(500))
    BEGIN
    
        INSERT INTO `product`(`CODE`,`NAME`,`AUTHOR`, `CATEGORY`, `MATERIAL`, `PRICE`, `DESCRIPTION`, `COMMENT`) 
        VALUES (`prCode` ,`prName`,`prAuthor`,`prCategory` ,`prMaterial`,`prPrice`,`prDescription`,`prComment`);
    
    END//
    
    点赞 评论 复制链接分享