0

Work with mysql on phpMyAdmin

SQL :

drop PROCEDURE if EXISTS mi;

CREATE PROCEDURE mi()  //<-- line 3
BEGIN
  INSERT INTO User ( `name` , `password` ) VALUES ('value1', 'value2');
  SET out_param = LAST_INSERT_ID();
END

CALL mi();

the 'drop' is for multi testing

we have table User there are id primary key , name varchar, password varchar

Error :

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 3

thanks for any help !

3
  • 1
    MySQL <> SQL Server, you need to remove the sql tag. Commented Jun 2, 2017 at 18:18
  • thank you for letting me know, the tag removed Commented Jun 2, 2017 at 18:20
  • add "delimiter $$"before create statement and "$$" after end statement, Commented Jun 2, 2017 at 18:33

2 Answers 2

1

By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server. To redefine the mysql delimiter, use the delimiter command.

You can read about this in more detail create procedure.

Add "delimiter //"before create statement and "//" after end statement in order to execute your procedure. You can use any other delimiter as well.

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

1 Comment

Is it helpful to you ?
0

In phpMyAdmin, you can set the delimiter on the SQL page, near the bottom, there is a line on the same area of the page as the Go button. Change the separator to anything ($$ is a common one) and then add this to the end of your script.

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.