title: Calling a stored procedure from a function
body: <p>I have the following stored procedure:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE SEARCH_SELECT (IN searchKey varchar(30), OUT id INT, OUT cmd VARCHAR(1024), OUT attr CHAR(10))
  
  LANGUAGE SQL
  READS SQL DATA 
      DYNAMIC RESULT SETS 1
  BEGIN
      DECLARE result_set_1 CURSOR WITH RETURN TO CLIENT FOR
          SELECT id, cmd, attr FROM test.commandtbl c WHERE c.attr = searchKey;   
      OPEN result_set_1;
  END!
  </code></pre>
  
  <p>And I want to call that from the following function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION select_selector (param VARCHAR(3))
  RETURNS TABLE (id INT, CMD VARCHAR(1024), ATTR CHAR(10))
  LANGUAGE SQL 
  READS SQL DATA 
  
  EXTERNAL ACTION 
  BEGIN
  
    call SEARCH_SELECT(param);
  
   END!
  </code></pre>
  
  <p>The reason why is that I need to call the result as a table like I do with a function i.e. </p>
  
  <pre><code>select * from table(select_selector('a'))
  </code></pre>
  
  <p>and not like a procedure </p>
  
  <pre><code>call SEARCH_SELECT('a')
  </code></pre>
  
  <p>How can I get that to work?</p>
  
  <p>The question here is how to call a stored procedure with a parameter from within a function and get the same result as the stored procedure would have returned so I can call the procedure like a table.  </p>