title: "Error #1313 RETURN is only allowed in a FUNCTION" When Creating a Stored Procedure in phpMyAdmin
body: <p>I'm trying to create the following stored procedure in phpMyAdmin. But, I keep getting this error: #1313 - RETURN is only allowed in a FUNCTION</p>
  
  <pre><code>CREATE PROCEDURE IS_POINT_IN_POLYGON()
  BEGIN
  DECLARE n INT DEFAULT 0;
  DECLARE pX DECIMAL(19,16);
  DECLARE pY DECIMAL(19,16);
  DECLARE ls LINESTRING;
  DECLARE poly1 POINT;
  DECLARE poly1X DECIMAL(19,16);
  DECLARE poly1Y DECIMAL(19,16);
  DECLARE poly2 POINT;
  DECLARE poly2X DECIMAL(19,16);
  DECLARE poly2Y DECIMAL(19,16);
  DECLARE i INT DEFAULT 0;
  DECLARE result INT(1) DEFAULT 0;
  SET pX = X(p);
  SET pY = Y(p);
  SET ls = ExteriorRing(poly);
  SET poly2 = EndPoint(ls);
  SET poly2X = X(poly2);
  SET poly2Y = Y(poly2);
  SET n = NumPoints(ls);
  WHILE i&lt;n DO
  SET poly1 = PointN(ls, (i+1));
  SET poly1X = X(poly1);
  SET poly1Y = Y(poly1);
  IF ( ( ( ( poly1X &lt;= pX ) 
  &amp;&amp; ( pX &lt; poly2X ) ) || ( ( poly2X &lt;= pX ) 
  &amp;&amp; ( pX &lt; poly1X ) ) ) 
  &amp;&amp; ( pY &gt; ( poly2Y - poly1Y ) * ( pX - poly1X ) / ( poly2X - poly1X ) + poly1Y ) ) THEN
  SET result = !result;
  END IF;
  SET poly2X = poly1X;
  SET poly2Y = poly1Y;
  SET i = i + 1;
  END WHILE;
  RETURN result;
  END//
  </code></pre>
  
  <p>How do I solve this problem? In the SQL pane, I remembered to change the delimiter to // .</p>
  
  <p>Any suggestions?</p>