title: Wrong MYSQL Create Function syntax?
body: <p>I'm trying to create a function like this in MYSQL:</p>
  
  <pre><code>DELIMITER $$
  CREATE FUNCTION `submit`(title VARCHAR(45)) RETURNS INT
    BEGIN
      DECLARE articleId INT;
      INSERT INTO Articles (`Title`) VALUES (title);
      SET @articleId = LAST_INSERT_ID();
      RETURN (articleId);
    END
  $$ DELIMITER ;
  </code></pre>
  
  <p>No matter how I change it (including removing everything in the body and placing a "return 1;"  instead) I get:</p>
  
  <blockquote>
    <p>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 '<em>DELIMITER $$ CREATE FUNCTION <code>submit</code>(title v</em>' at line 1</p>
  </blockquote>
  
  <p>What am I missing?</p>
  
  <p>I'm using MySQL 5.5</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Apparently, MySQL is ignoring the first statement (<code>DELIMITER $$</code>), failing on the first <code>;</code> it finds, right after <code>articleId INT</code> in the 4th line. I had to reduce the code to the shortest form possible to make sure that's the case.</p>
  
  <p>So I guess my question now is - Why is the <code>DELIMITER</code> keyword ignored?</p>