Monday 12 November 2018

MySQL error: 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

I have the Stored procedure like this:
CREATE PROCEDURE ProG()
  BEGIN
    SELECT * FROM `hs_hr_employee_leave_quota`;
  END
But it gives the 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 3
What does the error mean? What is wrong with line number 2?

 Answers


You have to change delimiter before using triggers, stored procedures and so on.
delimiter //
create procedure ProG() 
begin 
SELECT * FROM hs_hr_employee_leave_quota;
end;//
delimiter ;



Delimiters, delimiters...
You really need them when there are multiple statements in your procedure. 
(in other words, do you have a ; in your code and then more statements/commands? 
Then, you need to use delimiters).
For such a simpler rpocedure as yours though, you could just do:
CREATE PROCEDURE ProG()
  SELECT * FROM `hs_hr_employee_leave_quota`;

0 comments:

Post a Comment