title: PL/SQL Select and Update statement inside OPEN - FOR
body: <p>So I have a pl/sql function and I want to select and update table inside open for statement
  It looks like this:</p>
  <p>table_a</p>
  <p>id | status | document_id |</p>
  <pre><code>create or replace function a(p_document_id in number)
      return sys_refcursor
      is
      result sys_refcursor;
  begin
      open result for
          select id
          from table_a t
          where t.document_id = p_document_id;
  
      update table_a t
      set t.status = 1
      where id in (select id
          from table_a t
          where t.document_id = p_document_id);
  
      return result;
  
  end;
  /
  </code></pre>
  <p>But it is not working. Is there some method to do this? thanks in advance</p>