title: Can I update the result (sys_refcursor) of an Oracle stored procedure (in Java)?
body: <p>Given the following function:</p>
  
  <pre><code>create or replace FUNCTION "GETADDRESSES"
      RETURN sys_refcursor
  IS
      address_cursor sys_refcursor;
  BEGIN
      OPEN address_cursor FOR 
          SELECT * FROM Address;
      RETURN address_cursor;
  END;
  </code></pre>
  
  <p>I would like to be able to make changes to this result set in Java and post the changes back to the database. It is called in Java with the following:</p>
  
  <pre><code>        String genericQuery = "{ call ? := getAddresses() }";
          CallableStatement stmt = connection.prepareCall(genericQuery, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
  
         stmt.registerOutParameter(1, OracleTypes.CURSOR);
         stmt.execute();
         ResultSet rs = (ResultSet)stmt.getObject(1);
         while (rs.next())
         {
             System.out.println (rs.getString(2)); 
             rs.updateString(2, "*" + rs.getString(2));
         }
         stmt.close();
  </code></pre>
  
  <p>which raises an exception "Invalid operation for read only resultset". Is there a way to return this cursor as something which can be updated and posted back to the db from Java? I am using Oracle 10g.</p>
  
  <p>Thanks, Rob</p>