0

I have a problem with the stored procedure of getallfiles. When I execute that stored procedure, I got an error message that says:

"Error

SQL query:

CREATE PROCEDURE GetAllFiles()
BEGIN
     DECLARE CheckExists int

MySQL said: Documentation

#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"

Here's my stored procedure

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;  
juergen d
  • 201,996
  • 37
  • 293
  • 362
  • this is line 3: `# declaring checkexists for if the files exists` – juergen d Aug 16 '16 at 18:47
  • those are actually comments – Jamie Smith Aug 16 '16 at 18:48
  • 1
    your db engine does not know that – juergen d Aug 16 '16 at 18:48
  • I took out all of the comments and when I executed I got an error message that says: Error SQL query: CREATE PROCEDURE GetAllFiles() BEGIN DECLARE CheckExists int MySQL said: Documentation #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 4" – Jamie Smith Aug 16 '16 at 18:49
  • Read my answer to http://stackoverflow.com/questions/745538/create-function-through-mysqldb/745575#745575 – Bill Karwin Aug 16 '16 at 19:00
  • Unfortutnately that doesn't answer my question. Also I already have delimiter on the checkbox on phpmyadmin in this link and there no need to have delimiter: https://www.dropbox.com/s/wmbgqpdiu6wsh6z/getallfiles%20procedure.jpg?dl=0 – Jamie Smith Aug 16 '16 at 20:08

0 Answers0