tfbsr
asked on
reading total number of row with preparedstatement
Expert Exchange
Is there a way to read the total number of rows from a select satement using prepared statement, instead of having to loop throght the data and count as you go?
rs1 = getIP.getResultSet();
while (rs1.next())
packIP(rs1.getString(1));
but instead
int total = command
Thanks
Is there a way to read the total number of rows from a select satement using prepared statement, instead of having to loop throght the data and count as you go?
rs1 = getIP.getResultSet();
while (rs1.next())
packIP(rs1.getString(1));
but instead
int total = command
Thanks
What language are you using? Most have something like rs1.RecordCount as a function that can be referenced once the rs1 has been populated.
ASKER
Using Java
Sorry - don't know much about Java. pitster's initial response will work for any query language so if you can't find another way it should get you there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Select Count(myTable.*) as Total
From myTable
That should return 1 row with a value and a column header 'Total'
Good Luck!!!