1

I created a MySQL script that creates a Stored Procedure which Inserts a new row into a table given the IN parameters of the Stored Procedure. However, when we try to run the script, this error is shown:

ERROR 1064 (42000) at line 22: 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 3

This is basically the stored procedure in the script file:

CREATE PROCEDURE 'packagename'.`procedureName`
(IN param1 DATE, 
 IN param2 TIME, 
 IN param3 VARCHAR(45), 
 IN param4 VARCHAR(100))
BEGIN
    INSERT INTO packagename.table (`param1`, `param2`, `param3`, `param4`) 
    VALUES (param1, param2, param3, param4);
END;

Any ideas?

1 Answer 1

1
  • change DELIMITER
  • use backtick instead of single quote in the package name
  • if the name of your table is table in packagename.table, escape it with backtick

query,

DELIMITER $$
CREATE PROCEDURE `packagename`.`procedureName`
(
      IN param1 DATE, 
      IN param2 TIME, 
      IN param3 VARCHAR(45), 
      IN param4 VARCHAR(100)
)
BEGIN
     INSERT INTO packagename.`table` (`param1`, `param2`, `param3`, `param4`) 
            VALUES (param1, param2, param3, param4);
END $$
DELIMITER ;
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this, however, I got a different error message: ERROR 1064 (42000) at line 23: 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 'DELIMETER $$ CREATE PROCEDURE

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.