为什么我一直在mysql存储过程中收到错误信息

时间:2016-08-16 18:46:03

标签: mysql

我的getallfiles存储过程有问题。当我执行该存储过程时,我收到一条错误消息:

“错误

SQL查询:

CREATE PROCEDURE GetAllFiles()
BEGIN
     DECLARE CheckExists int

MySQL说:文档

  

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

这是我的存储过程

CREATE PROCEDURE GetAllFiles()
BEGIN
 # declaring checkexists for if the files exists
    DECLARE CheckExists int;  
    DECLARE specialty CONDITION FOR SQLSTATE '45000';
    SET CheckExists = 0;  
   # checking to see how many files are there
    SELECT COUNT(files.Files,Users.FirstName,Users.LastName,Users.EmailAddress) INTO CheckExists from
     files,Users where files.UserID = Users.UserID;

  # checking to see if the files exists
    IF (CheckExists < 0) THEN 
         SIGNAL SQLSTATE '45000'
      SET MESSAGE_TEXT = 'Files does not exists';
    ELSE 
        select files.Files,Users.firstname,Users.lastname,Users.EmailAddress from files,Users
where files.UserID = Users.UserID;  
    END IF; 


END;  

0 个答案:

没有答案