#1064 - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以获得正确的语法

时间:2015-08-01 07:58:39

标签: mysql sql stored-procedures syntax-error

我写了一个MySQL存储过程:

CREATE PROCEDURE add_Customer
     (
        IN  p_customer_id                   INT(11)       , 
        IN  p_Email                         VARCHAR(70)   , 
        IN  p_password                      VARCHAR(15)   ,        
        IN  p_firstname                     VARCHAR(40)   , 
        IN  p_lastname                      VARCHAR(40)   , 
        IN  p_birth_date                    DATE          ,
        IN  p_gender                        VARCHAR(20)   ,      
        IN  p_address_1                     VARCHAR(200)  ,
        IN  p_address_2                     VARCHAR(200)  ,
        IN  p_city                          VARCHAR(40)   ,    
        IN  p_state                         VARCHAR(40)   ,
        IN  p_country                       VARCHAR(50)   ,
        IN  p_phoneNumber                   VARCHAR(20)   ,
        IN  p_postalcode                    VARCHAR(10)   ,
        IN  p_billingAddress                VARCHAR(200)  ,
        IN  p_billingCity                   VARCHAR(60)   ,
        IN  p_billingCountry                VARCHAR(70)   ,
        IN  p_billingState                  VARCHAR(70)   ,
        IN  p_billing_Zip_code              VARCHAR(15)   ,
        IN  p_shippingAddress               VARCHAR(250)  ,
        IN  p_shippingCity                  VARCHAR(50)   ,
        IN  p_shippingCountry               VARCHAR(60)   ,
        IN  p_shippingState                 VARCHAR(60)   ,
        IN  p_shipping_zip_code             VARCHAR(15)   ,
        IN  p_credit_card_number            VARCHAR(20)   ,
        IN  p_name_on_creditCard            VARCHAR(70)   ,
        IN  p_credit_card_type              VARCHAR(20)   ,
        IN  p_cardSecurityCode              INT(4)        ,
        IN  p_card_exp_date                 DATE          ,
        IN  p_K_net_account                 VARCHAR(40)   ,
        IN  p_account_status                VARCHAR(30)   ,
        IN  p_email_verified                VARCHAR(20)   ,
        IN  p_registration_date             DATE          ,
        IN  p_verification_code             VARCHAR(20)   ,
        IN  p_last_login                    TIMESTAMP        )              



BEGIN 

    INSERT INTO customer
         (
            CustomerID          ,
            CustomerEmail       ,
            CustomerPassword    ,
            FirstName           ,
            LastName            ,
            DateOfBirth         ,
            Gender              ,
            Address_1           ,
            Address_2           ,
            City                ,
            Region              ,
            Country             ,
            PhoneNumber         ,
            PostalCode          ,
            BillingAddress      ,
            BillingCity         ,
            BillingState        ,
            BillingCountry      ,
            BillingPostalCode   ,
            ShippingAddress     ,
            ShippingCity        ,
            ShippingState       ,
            ShippingCountry     ,
            ShippingPostalCode  ,
            CreditCardType      ,
            CreditCardNumber    ,
            NameOnCreditCard    ,
            CardSecurityCode    ,
            CardExpDate         ,
            K_NetAccount        ,
            AccountStatus       ,
            VerivecationCode    ,
            EmailVerified       ,
            RegistrationDate    ,
            LastLogin           ,
          )  

       VALUES
         ( 
          p_customer_id                     , 
          p_Email                           , 
          p_password                        ,        
          p_firstname                       , 
          p_lastname                        , 
          p_birth_date                      ,
          p_gender                          ,      
          p_address_1                       ,
          p_address_2                       ,
          p_city                            ,    
          p_state                           ,
          p_country                         ,
          p_phoneNumber                     ,
          p_postalcode                      ,
          p_billingAddress                  ,
          p_billingCity                     ,
          p_billingState                    ,
          p_billingCountry                  ,
          p_billing_Zip_code                ,
          p_shippingAddress                 ,
          p_shippingCity                    ,
          p_shippingState                   ,
          p_shippingCountry                 ,      
          p_shipping_zip_code               ,
          p_credit_card_type                ,
          p_credit_card_number              ,
          p_name_on_creditCard              ,
          p_cardSecurityCode                ,
          p_card_exp_date                   ,
          p_K_net_account                   ,
          p_account_status                  ,
          p_verification_code               ,
          p_email_verified                  ,
          p_registration_date               ,               
          p_last_login                   )     
END 

并在执行时显示此消息

  

“#1064 - 您的SQL语法出错;请查看手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近')VALUES(p_customer_id'在第80行“

我该如何解决?

2 个答案:

答案 0 :(得分:1)

您在columns子句中的右括号(,)之前有一个冗余逗号())。

INSERT INTO customer
     (
        CustomerID          ,
        CustomerEmail       ,
        CustomerPassword    ,
        FirstName           ,
        LastName            ,
        DateOfBirth         ,
        Gender              ,
        Address_1           ,
        Address_2           ,
        City                ,
        Region              ,
        Country             ,
        PhoneNumber         ,
        PostalCode          ,
        BillingAddress      ,
        BillingCity         ,
        BillingState        ,
        BillingCountry      ,
        BillingPostalCode   ,
        ShippingAddress     ,
        ShippingCity        ,
        ShippingState       ,
        ShippingCountry     ,
        ShippingPostalCode  ,
        CreditCardType      ,
        CreditCardNumber    ,
        NameOnCreditCard    ,
        CardSecurityCode    ,
        CardExpDate         ,
        K_NetAccount        ,
        AccountStatus       ,
        VerivecationCode    ,
        EmailVerified       ,
        RegistrationDate    ,
        LastLogin           -- Comma removed here
      )  

   VALUES
      -- Snipped

答案 1 :(得分:0)

删除

中的尾随“,”(逗号)
LastLogin           ,

                    ^
                    |