简体   繁体   中英

Error 1064 in a stored procedure in MySQL 8.0

I am using MySQL Workbench 8.0 CE and i'm trying to create a stored procedure to show 2 fields from my table. I am receiving 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 3

This is my table:

CREATE TABLE student (
 id INT PRIMARY KEY,
 name VARCHAR(200),
 age INT,
 final_grade DOUBLE,
 sex VARCHAR(1)
)

And this is the procedure:

CREATE PROCEDURE show_name_grade () 
 BEGIN
  SELECT name,final_grade FROM student;
END

You will need to redefine Delimiter to something else other than ; . At the end, define it back to ;

DELIMITER $$
CREATE PROCEDURE show_name_grade () 
 BEGIN
  SELECT name,final_grade FROM student;
END $$
DELIMITER ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM