title: SQL: Not allowed to return a result set from a function
body: <p>I have an SQL Function called <code>compare_two_regions</code> that returns the datatype <code>BIT</code>, I want to call this function on a function called <code>compare_two_series</code>.
  I simplified this function to the point where i only want to return the value from the <code>compare_two_regions</code> function. Still I would like to call the <code>compare_two_regions</code> function under a loop, but even in this simplified case:</p>
  
  <pre><code>DELIMITER $$
  
  create function compare_two_series( serieA varchar(255), serieB varchar(255)) 
  returns BIT 
  begin
  declare result BIT;
  
  /*falta ver*/
  SELECT P1.x1,P1.y1,P1.x2,P1.y2,P2.x1,P2.y1,P2.x2,P2.y2
  FROM region as P1, region as P2
  WHERE P1.region.series_id = serieA AND P2.region.series_id = serieB;
  
  SELECT compare_two_regions(P1.x1,P1.y1,P1.x2,P1.y2,P2.x1,P2.y1,P2.x2,P2.y2) into result;
  return result;
  end$$
  DELIMITER ;
  </code></pre>
  
  <p>I get the following error: <code>Not allowed to return a result set from a function</code></p>