MySQL错误:SQL语法有错误;检查与MySQL服务器版本相对应的手册,以获得使用near的正确语法

时间:2021-01-29 22:46:00

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

#1064 - SQL语法有错误;请检查与MySQL服务器版本对应的手册,以获得在“第3行”附近使用的正确语法

What does the error mean? What is wrong with line number 2?

误差是什么意思?第2行有什么问题?

4 个解决方案

#1


53  

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 ;

#2


12  

How to find out what this MySQL Error is trying to say:

如何找出这个MySQL错误的含义:

#1064 - You have an error in your SQL syntax;

This error has no clues in it. You have to double check all of these items to see where your mistake is:

这个错误没有任何线索。你必须仔细检查所有这些项目,看看你的错误在哪里:

  1. You have omitted, or included an unnecessary symbol: !@#$%^&*()-_=+[]{}\|;:'",<>/?
  2. 你有遗漏,或包含一个不必要的象征:! @ # $ % ^ & *()_ = +[]{ } \ |;:”,< > / ?
  3. A misplaced, missing or unnecessary keyword: select, into, or countless others.
  4. 一个错位的、丢失的或不必要的关键字:选择、进入或数不清的其他关键词。
  5. You have unicode characters that look like ascii characters in your query but are not recognized.
  6. 查询中的unicode字符看起来像ascii字符,但不能识别。
  7. Misplaced, missing or unnecessary whitespace or newlines between keywords.
  8. 在关键字之间放错位置、丢失或不必要的空格或换行。
  9. Unmatched single quotes, double quotes, parenthesis or braces.
  10. 单引号,双引号,括号或括号。

Take away as much as you can from the broken query until it starts working. And then use PostgreSQL next time that has a sane syntax reporting system.

在中断的查询开始工作之前,尽可能地删除它。然后下次使用PostgreSQL,它有一个健全的语法报告系统。

#3


5  

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`;

#4


0  

This might be a memmory issue on mysql try to increase max_allowed_packet in my.ini

这可能是mysql的一个memmory问题,试图增加my.ini中的max_allowed_packet。

#1


53  

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 ;

#2


12  

How to find out what this MySQL Error is trying to say:

如何找出这个MySQL错误的含义:

#1064 - You have an error in your SQL syntax;

This error has no clues in it. You have to double check all of these items to see where your mistake is:

这个错误没有任何线索。你必须仔细检查所有这些项目,看看你的错误在哪里:

  1. You have omitted, or included an unnecessary symbol: !@#$%^&*()-_=+[]{}\|;:'",<>/?
  2. 你有遗漏,或包含一个不必要的象征:! @ # $ % ^ & *()_ = +[]{ } \ |;:”,< > / ?
  3. A misplaced, missing or unnecessary keyword: select, into, or countless others.
  4. 一个错位的、丢失的或不必要的关键字:选择、进入或数不清的其他关键词。
  5. You have unicode characters that look like ascii characters in your query but are not recognized.
  6. 查询中的unicode字符看起来像ascii字符,但不能识别。
  7. Misplaced, missing or unnecessary whitespace or newlines between keywords.
  8. 在关键字之间放错位置、丢失或不必要的空格或换行。
  9. Unmatched single quotes, double quotes, parenthesis or braces.
  10. 单引号,双引号,括号或括号。

Take away as much as you can from the broken query until it starts working. And then use PostgreSQL next time that has a sane syntax reporting system.

在中断的查询开始工作之前,尽可能地删除它。然后下次使用PostgreSQL,它有一个健全的语法报告系统。

#3


5  

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`;

#4


0  

This might be a memmory issue on mysql try to increase max_allowed_packet in my.ini

这可能是mysql的一个memmory问题,试图增加my.ini中的max_allowed_packet。