Given the following function:
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;
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:
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();
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.
Thanks, Rob