can any one giuve solution of how to identify the number of records a result set obejct is having
for ex
select * from employees fetches all the records into a result set object i want to find the number of records or number of rows this result set is having any particular method to know the row size
-
number of rows in a resultset (3 messages)
- Posted by: srinivas varaha
- Posted on: September 14 2001 00:55 EDT
Threaded Messages (3)
- number of rows in a resultset by Gal Binyamini on September 14 2001 16:47 EDT
- number of rows in a resultset by Toby Hede on September 14 2001 20:34 EDT
- number of rows in a resultset by srinivas varaha on September 15 2001 02:00 EDT
-
number of rows in a resultset[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: September 14 2001 16:47 EDT
- in response to srinivas varaha
One option is:
rs.last();
int numOfRows = rs.getRow();
I don't have the API in front of me - there may be a direct method for this, but I don't remember any.
Note that if all you need is the count, it may be faster to select the count directly in SQL.
Gal -
number of rows in a resultset[ Go to top ]
- Posted by: Toby Hede
- Posted on: September 14 2001 20:34 EDT
- in response to Gal Binyamini
Using "SELECT *, Count(pk) FROM Employees" may be faster in terms of brute processing performance but the extra data transmitted along the wire (the count data is added to every row) may slow overall performance.
The alternative is to make two queries, one to get the count and th other the data itself, but this is probably worse for obvious reasons.
Depends where the load on the system lies, I guess, but I would be tempted to handle the count in the App Server, using the aforementioned technique:
rs.last();
int numOfRows = rs.getRow();
-
number of rows in a resultset[ Go to top ]
- Posted by: srinivas varaha
- Posted on: September 15 2001 02:00 EDT
- in response to Gal Binyamini
rs.last();
int numOfRows =rs.getRow();
it worked only if i set the cursor in con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY)
other wise i get an error that Result Set is mapped to TYPE_FORWARD_ONLY
i dont want to set the cursor since it reduces the performance so any other solution to overcome this scenario