Home » RDBMS Server » Server Administration » Return type of count
Return type of count [message #372867] Wed, 14 March 2001 20:35 Go to next message
jazelle
Messages: 2
Registered: March 2001
Junior Member
I'm using ResultSet in java.sql to retrieve the no. of rows in a table. How can i cast the result back to int since the return type from COUNT(*) should be an interger? Thanx.
Re: Return type of count [message #372870 is a reply to message #372867] Wed, 14 March 2001 23:50 Go to previous messageGo to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
If u are returning the rows of the SELECT query to the vector then user <result set name>.getNumRows()

If the result of the count is returned to the result set..,please use <result set name>.getRowData(i,1).intValue()

This will solve the purpose...

Regards
Jay
Re: Return type of count [message #372871 is a reply to message #372867] Thu, 15 March 2001 00:12 Go to previous messageGo to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
If u are returning the rows of the SELECT query to the vector then we have to traverse the resultset to get the number of rows

If the result of the count is returned to the result set..,please use <result set name>.getRowData(i,1).parseInt()

This will solve the purpose...

Regards
Jay
Re: Return type of count [message #372872 is a reply to message #372867] Thu, 15 March 2001 00:14 Go to previous messageGo to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
If u are returning the rows of the SELECT query to the vector then we have to traverse the resultset to get the number of rows

If the result of the count is returned to the result set..,please use <result set name>.getRowData(i,1).parseInt()

This will solve the purpose...

Regards
Jay
Re: Return type of count [message #372899 is a reply to message #372870] Fri, 16 March 2001 03:37 Go to previous message
jazelle
Messages: 2
Registered: March 2001
Junior Member
Fron your reply, i think you are implying that i can choose the return type from this statement
"SELECT COUNT(*) FROM table1". But since i'm using statement.executeQuery, isn't the return type fixed to be a RecordSet?
Previous Topic: Concurent insertion & deletion on same table
Next Topic: Decode help
Goto Forum:
  


Current Time: Sat Jun 29 00:50:43 CDT 2024