0

I am trying to create a procedure to update my database with multiple parameters. Here is my code:

DELIMITER //    
CREATE PROCEDURE updateImages (IN stagingID INT, IN streetName VARCHAR(50), IN numberOfImages INT)

BEGIN
DECLARE count INT;
SET count = 1;

    WHILE count < (numberOfImages + 1) DO
        SET fileName = CONCAT(streetName, ' (mls) (', count, ').jpg');
        INSERT INTO images_tbl VALUES
       (NULL, stagingID, fileName, 0);
       SET count = count + 1;
    END WHILE;
END //
DELIMITER ;

PHPMyAdmin is giving me a blank #1193 error with no other information. I've tried to search and implement the resolutions I have found regarding this error, but have not been able to figure it out.

Any ideas would be very welcome. Thanks in advance.

4
  • include a line for DECLARE fileName varchar(200); or the like. works on my system with no 1193 Commented Oct 17, 2015 at 1:10
  • Oh, wow. It's always the little things that get overlooked. Thank you @Drew! Edit: Now I am getting a blank #1064 error, which I think is the syntax error? I declared the fileName below the count declaration Commented Oct 17, 2015 at 2:03
  • aint that the truth JG Commented Oct 17, 2015 at 2:06
  • Second Edit: Nevermind, I had something else wrong. Thank you again! Commented Oct 17, 2015 at 2:10

1 Answer 1

1

As @Drew pointed out, I omitted a declaration for fileName. Final Code:

DELIMITER //
CREATE PROCEDURE updateImages (IN stagingID INT, IN streetName VARCHAR(50), IN numberOfImages INT)

BEGIN
    DECLARE count INT;
    DECLARE fileName VARCHAR(100);
    SET count = 1;

    WHILE count < (numberOfImages + 1) DO        
        SET fileName = CONCAT(streetName, ' (mls) (', count, ').jpg');
        INSERT INTO images_tbl VALUES (NULL, stagingID, fileName, 0);
        SET count = count + 1;
    END WHILE;

END //
DELIMITER ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.