2

I am getting a syntax error at simple_loop: Loop statement saying

Unexpected character near ':' 

in the line simple_loop: LOOP

Please help

DELIMITER $$  

CREATE PROCEDURE getTable(fullstr VARCHAR(555))

   BEGIN
      DECLARE a INT Default 0 
      DECLARE str VARCHAR(255)
      simple_loop: LOOP
         SET a=a+1
         SET str=SPLIT_STR(fullstr,",",a)
         IF str='' THEN
            LEAVE simple_loop
         END IF
         #Do Inserts into temp table here with str going into the row
         insert into my_temp_table values (str)
   END LOOP simple_loop
END $$
3

1 Answer 1

1

It is a very annoying MySQL syntax related issue: There is a TAB somewhere in you procedure leading to this parse issue.

Note: Separate ;

DELIMITER $$  

    CREATE PROCEDURE getTable(fullstr VARCHAR(555))

       BEGIN
          DECLARE a INT Default 0 ;
          DECLARE str VARCHAR(255);
          simple_loop: LOOP
             SET a=a+1;
             SET str=SPLIT_STR(fullstr,",",a);
             IF str='' THEN
                LEAVE simple_loop;
             END IF;
             #Do Inserts into temp table here with str going into the row
             insert into my_temp_table values (str);
       END LOOP simple_loop;
    END $$
Sign up to request clarification or add additional context in comments.

2 Comments

if I use ; , I see errors everywhere. So, had to remove it.
Note that ; is not needed everywhere. But it was missing several places.

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.