您的SQL语法有错误;检查与您的MariaDB服务器版本对应的手册,以便在第23行的''附近使用正确的语法

时间:2017-04-01 23:56:02

标签: mysql sql mariadb

我尝试使用以下Mysql Query来创建过程,但我总是收到错误:

 #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 23

这是我的SQL语句,基本上我希望得到,设置,更新我的数据信息。

USE AddressBook;
    DELIMITER $$
    CREATE PROCEDURE CreateContact (
                IN FirstName_IN VARCHAR(50) = null,
      IN LastName_IN VARCHAR(50) = null,
      IN Phone_IN VARCHAR(20) = null,
      IN Email_IN VARCHAR(50) = null,
      IN Address_IN VARCHAR(100) = null,
      IN City_IN VARCHAR(30) = null,
      IN State_IN VARCHAR(30) = null,
      IN Country_IN VARCHAR(30) = null,
      IN PostalCode_IN VARCHAR(10) = null,
      OUT id INT)
    BEGIN
      INSERT INTO AddressBook.Contact (
        FirstName,
        LastName,
        Phone,
        Email,
        Address,
        City,
        State,
        Country,
       PostalCode)
       VALUES (FirstName_IN, LastName_IN, Phone_IN, Email_IN, Address_IN, City_IN, State_IN, Country_IN, PostalCode_IN)$$
    END$$
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.CreateContactImage (
              IN FirstName_IN VARCHAR(50) = null,
      IN LastName_IN VARCHAR(50) = null,
      IN Phone_IN VARCHAR(20) = null,
      IN Email_IN VARCHAR(50) = null,
      IN Address_IN VARCHAR(100) = null,
      IN City_IN VARCHAR(30) = null,
      IN State_IN VARCHAR(30) = null,
      IN Country_IN VARCHAR(30) = null,
      IN PostalCode_IN VARCHAR(10) = null,
      Id INT OUTPUT)
    BEGIN
      INSERT INTO AddressBook.Contact (
        FirstName,
        LastName,
        Phone,
        Email,
        Address,
        City,
        State,
        Country,
       PostalCode)
       VALUES (FirstName_IN, LastName_IN, Phone_IN, Email_IN, Address_IN, City_IN, State_IN, Country_IN, PostalCode_IN)
    END$$;
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.CreateContactImage (
    IN ImageName_IN VARCHAR(50),
    IN ImagePath_IN VARCHAR(21844),
    IN ContactId_IN INT,
    Id INT OUTPUT)
    BEGIN
    INSERT INTO AddressBook.ContactImage (ImageName,ImagePath,ContactId)
         VALUES (ImageName_IN,ImagePath_IN,ContactId_IN)
    END$$;
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.DeleteContact (
    Id_IN INT)
    BEGIN
    DELETE FROM AddressBook.Contact
          WHERE Id = Id_IN
    END$$;
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.GetAllContacts ()
    BEGIN
    SELECT *  FROM dbo.Contact
    END$$;
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.GetAllImageByContactId (
    ContactId_IN INT)
    BEGIN
    SELECT * FROM  AddressBook.ContactImage
               where ContactId = ContactId_IN
    END$$;
    DELIMITER $$;
    CREATE PROCEDURE AddressBook.GetContactById (
    Id_IN INT)
    BEGIN
    select *  FROM AddressBook.Contact
          WHERE Id = Id_IN
    END$$;
    DELIMITER $$;
    create procedure AddressBook.UpdateContact
    FirstName_IN VARCHAR(50) = null,
      LastName_IN VARCHAR(50) = null,
      Phone_IN VARCHAR(20) = null,
      Email_IN VARCHAR(50) = null,
      Address_IN VARCHAR(100) = null,
      City_IN VARCHAR(30) = null,
      State_IN VARCHAR(30) = null,
      Country_IN VARCHAR(30) = null,
      PostalCode_IN VARCHAR(10) = null,
      Id_IN INT)
    BEGIN
    UPDATE AddressBook.Contact
       SET FirstName = FirstName_IN
          ,LastName = LastName_IN
          ,Phone = Phone_IN
          ,Email = Email_IN
          ,Address = Address_IN
          ,City = City_IN
          ,State = State_IN
          ,Country = Country_IN
          ,PostalCode = PostalCode_IN
     WHERE Id = Id_IN
     END$$;
     DELIMITER ;

任何人都可以帮我修复此错误吗?

1 个答案:

答案 0 :(得分:0)

我相信你在这里也缺少一个左括号:

create procedure AddressBook.UpdateContact

......应该是:

create procedure AddressBook.UpdateContact(