row count help

I am connecting to an IBM iSeries DB2 database from a windows platform. I have a simple program which connects from windows and executes some stored procedures on the DB.

I was wondering if there is a function in java which returns the number of rows affected by a certain stored procedure call.

If not, what is the best way to find out the number of rows affected by any particular stored procedure execution?

Thanks.

[443 byte] By [rw263@cam.ac.uk] at [2007-11-26 12:17:01]
# 1

I was wondering if there is a function in java which returns the number of rows affected by a certain stored procedure call.

No.

If not, what is the best way to find out the number of rows affected by any particular stored procedure execution?

IF your database provides a tool to obtain this information, the best way would be to determine from this the figure that you need and return it from the sproc. I don't know of such a facility in any of the databases that I use, but I don't know for certain that it doesn't exist.

Note that you may be assuming that this would be "simple" to track, but the side effects of triggers and the like would in fact make it quite complex. It could be done, but I don't know that it is done since it would be of very limited utility.

dcminter at 2007-7-7 14:53:57 > top of Java-index,Archived Forums,Socket Programming...
# 2
Thanks for the info.One more question. Say I want to return a single value from my sproc to java. How do I retrieve this value from the sproc?
rw263@cam.ac.uk at 2007-7-7 14:53:57 > top of Java-index,Archived Forums,Socket Programming...
# 3
Make it an out parameter, and register it in the CallableStatement you're invoking the sproc with.
dcminter at 2007-7-7 14:53:57 > top of Java-index,Archived Forums,Socket Programming...
# 4

>

> If not, what is the best way to find out the number

> of rows affected by any particular stored procedure

> execution?

The best way, and I suspect in general the only way, is to have the stored procedure specifically return a number that tells you what it did.

jschell at 2007-7-7 14:53:57 > top of Java-index,Archived Forums,Socket Programming...