Great, now I know how to get this information "inside the DB". Here is a follow-up question: How can I use this information inside a Java program. I guess the value of the ROWCOUNT variable must be returned in a ResultSet in some way, but how? This query does _not_ work:
select SQL%ROWCOUNT from dual
As a SQL statement passed through a JDBC driver - I don't know how you could do that. However, a possible workaround might be to have a generic procedure on the database side. You could then put in a call to the procedure and get the number of rows affected passed back to you:
PROCEDURE generic_call(p_command IN VARCHAR2, p_rows IN OUT NUMBER) IS
BEGIN
EXECUTE IMMEDIATE p_command;
p_rows := sql%rowcount;
END;
Now, instead of issuing a sql command, your application would declare a variable (rows_affected), and place a call:
generic_call('delete from TABLE where id=502',rows_affected)
After the call completes, you can examin rows_affected to see how many rows were updated/deleted.
It's a bit klugey (as most work-arounds are!) and it may or may not work for you. But it's about the best I can do today!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.