title: Function to return a cursor in PL SQL,
body: <p>I have a function which returns a SYS_REFCURSOR, this function is to be called from different packages and we don't want to have to duplicate the cursor definition in multiple places.</p>
  
  <pre><code>FUNCTION f_get_cur(p_date DATE, p_code VARCHAR(10)) RETURN SYS_REFCURSOR IS
    cur_s SYS_REFCURSOR;
  BEGIN
    OPEN cur_s FOR
      SELECT .blah blah etc etc
  
    return cur_s;
  END f_get_cur;
  </code></pre>
  
  <p>Which compiles ok, however when I want to use the function in a FOR LOOP where I'd normally put the cursor I get the following error</p>
  
  <blockquote>
    <p>Error: PLS-00456: item 'f_get_cur' is not a cursor</p>
  </blockquote>
  
  <p>I'm attempting to open the cursor like so...</p>
  
  <pre><code>FOR cc_rec IN f_get_cur(c_date, p_c_code) LOOP
  </code></pre>
  
  <p>Am I using the wrong data type? Is there some other way of achieving what I'm trying?</p>