0

I am trying to create stored Procedure using Mysql version 5.6.11 but it showing some error, here is my Code.

 CREATE PROCEDURE Debug(Message TEXT)
    BEGIN
    CREATE TABLE IF NOT EXISTS _debug (
        id int(10) unsigned NOT NULL auto_increment,
        msg TEXT DEFAULT NULL,
        created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (id)
     );
 INSERT INTO _debug(`msg`) VALUES(Message);
 END; 

I am getting this error:

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

BRBT
  • 1,467
  • 8
  • 28
  • 48
Sanjay
  • 1,958
  • 2
  • 17
  • 25
  • What client are you using to create it? For some (notably the mysql command line client) you must set the `DELIMITER` See http://stackoverflow.com/questions/10259504/delimiters-in-mysql – Michael Berkowski Mar 13 '14 at 13:07
  • The fact that you used `;` after `END` suggests the delimiter is not being handled correctly... – Michael Berkowski Mar 13 '14 at 13:07
  • I am using php myadmin. and belowed answer giving this error '#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 'delmiter $$ CREATE PROCEDURE Debug(Message TEXT) BEGIN CREATE TABLE I' at line 1' – Sanjay Mar 13 '14 at 13:16
  • PHPMyAdmin has its own different method of setting the delimiter. The command `DELIMITER` is specific to the mysql CLI client. There should be an input field in PHPMyAdmin to set a custom delimiter like `$$`. Set that field and end the procedure with `END$$`. – Michael Berkowski Mar 13 '14 at 13:19

1 Answers1

0

Remove the ;

delmiter $$
CREATE PROCEDURE Debug(Message TEXT)
    BEGIN
    CREATE TABLE IF NOT EXISTS _debug (
        id int(10) unsigned NOT NULL auto_increment,
        msg TEXT DEFAULT NULL,
        created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (id))
 INSERT INTO _debug(`msg`) VALUES(Message)
 END$$
Up_One
  • 5,213
  • 3
  • 33
  • 65