title: When building procedure, get error "SELECT not valid input at this position"
body: <p>Figured this would be a common issue, but after scanning the interviews for the last hour, apparently not.</p>
  
  <p>In a nutshell, I'm attempting to put a common query that is used into a procedure. Here's what I have so far.</p>
  
  <pre><code>DROP PROCEDURE IF EXISTS splitColumnsDelimiter;
  
  CREATE PROCEDURE splitColumnsDelimiter(IN DELIMITER VARCHAR(5))
  BEGIN
  SELECT
    sometbl.id,
    SUBSTRING_INDEX(SUBSTRING_INDEX(sometbl.name, '|', numbers.n), '|', -1) name
  FROM
    (SELECT 1 n UNION ALL SELECT 2
     UNION ALL SELECT 3 UNION ALL SELECT 4) numbers INNER JOIN sometbl
    ON CHAR_LENGTH(sometbl.name)
       -CHAR_LENGTH(REPLACE(sometbl.name, '|', ''))&gt;=numbers.n-1
  ORDER BY
    id, n
  
  END;
  </code></pre>
  
  <p>The query itself works like a charm. It seems however that adding any code to turn it into a procedure makes the workbench that i'm using pop up errors all over the place. From examples I've found on le internet, what I have should(?) be fine, but obviously not, so anyone happen to know where I might have been led astray, and where I can be enlightened? Figure this has to be pretty easy to do.</p>
  
  <p>EDIT: Here is the code that seems to have at least removed the error from occurring.</p>
  
  <pre><code>DROP PROCEDURE IF EXISTS splitColumnsDelimiter;
  
  DELIMITER //
  
  CREATE PROCEDURE splitColumnsDelimiter()
  BEGIN
  
  SELECT
        sometbl.id,
        SUBSTRING_INDEX(SUBSTRING_INDEX(sometbl.name, '|', numbers.n), '|', -1) name
      FROM
        (SELECT 1 n UNION ALL SELECT 2
         UNION ALL SELECT 3 UNION ALL SELECT 4) numbers INNER JOIN sometbl
        ON CHAR_LENGTH(sometbl.name)
           -CHAR_LENGTH(REPLACE(sometbl.name, '|', ''))&gt;=numbers.n-1
      ORDER BY
        id, n;
  
  END //
  DELIMITER ;
  </code></pre>
  
  <p>Executing a CALL splitColumnsDelimiter; now works as expected, returning the SQL table returns that I expected to see.</p>