title: Why does this function have a syntax error near DECLARE?
body: <p>The code is:</p>
  
  <pre><code>DELIMITER $$
  CREATE FUNCTION CHECK_AVABILITY(nama CHAR(30))
  RETURNS INT(4)
  DECLARE vreturn INT(4);
  BEGIN
  IF nama = 'ika' THEN
  SET vreturn = 0;
  ELSE
  SET vreturn = 1;
  END IF
  RETURN vreturn;
  END $$
  </code></pre>
  
  <p>The error message is:</p>
  
  <blockquote>
    <blockquote>
      <p>ERROR 1064 (42000): You Have an error inyour sql syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE vreturn INT4); BEGIN'</p>
    </blockquote>
  </blockquote>
  
  <p>Help is appreciated.</p>