0

I'm trying to run this query on MySQL server:

CREATE  PROCEDURE forum.eventlog_create(
i_UserID      INT,
i_Source      VARCHAR(128),
i_Description TEXT,
i_Type        INT,
i_UTCTIMESTAMP DATETIME)
MODIFIES SQL DATA
BEGIN

INSERT INTO forum.EventLog
(UserID, Source, Description, ´Type´)
VALUES (i_UserID, i_Source, i_Description, i_Type);

END;

However upon executing it I get the following error:

Error Code: 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 '' at line 12

and I'm unable to fix it. I tried to search for a solution and asked a co-worker but we were unable to find the solution, as last resort I decided to ask it here.

I get error code 1064 but the right syntax near '' is the message and I dont understand what the problem could be. It would be easier if it said which syntax gives the error, I only get the line number. Thank you for your time

14
  • 1
    Possible duplicate of How can I fix MySQL error #1064? Commented Jan 23, 2018 at 14:45
  • 2
    What MySQL client are you using to create this? It looks like you may need an alternate delimiter because the INSERT is terminated with ; but the procedure's END is as well. stackoverflow.com/questions/10259504/delimiters-in-mysql Commented Jan 23, 2018 at 14:46
  • 2
    Did you define another delimiter ? Commented Jan 23, 2018 at 14:46
  • 1
    The error is not unkown, the error has the number 1064. What is your MySQL version? Commented Jan 23, 2018 at 14:47
  • Does MySQL accept value inputs without string quotes like that? Seems bad. Commented Jan 23, 2018 at 14:48

2 Answers 2

3

There is one error caused by the escape character around type which should be either backticks or dropped and you should try setting delimiters https://dev.mysql.com/doc/refman/5.7/en/stored-programs-defining.html

delimiter $$

CREATE  PROCEDURE eventlog_create(
i_UserID      INT,
i_Source      VARCHAR(128),
i_Description TEXT,
i_Type        INT,
i_UTCTIMESTAMP DATETIME)
MODIFIES SQL DATA
BEGIN

INSERT INTO forum.EventLog
(UserID, Source, Description, `Type`)
VALUES (i_UserID, i_Source, i_Description, i_Type);

END $$

delimiter ;
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

DELIMITER $$
CREATE PROCEDURE forumeventlog_create() 
BEGIN 
declare i_UserID INT DEFAULT 0; 
declare i_Source VARCHAR(128) DEFAULT null; 
declare i_Description TEXT DEFAULT null; 
declare i_Type INT DEFAULT 0; 
declare i_UTCTIMESTAMP DATETIME DEFAULT null ; 

INSERT INTO forum.EventLog
(UserID, Source, Description, ´Type´)
VALUES (i_UserID, i_Source, i_Description, i_Type);

END $$
DELIMITER ;

You can call this by

CALL forumeventlog_create()

OR

 DELIMITER $$
   CREATE PROCEDURE forumeventlog_create(i_UserID INT,i_Source VARCHAR(128),i_Description TEXT,i_Type INT,i_UTCTIMESTAMP DATETIME) 
            BEGIN 
            INSERT INTO forum.EventLog 
    (UserID, Source, Description, ´Type´) 
        VALUES (i_UserID, i_Source, i_Description, i_Type); 

            END $$
            DELIMITER ;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.