numrows
numrows
От:
Ricardo Javier Aranibar León<ricardo_jal@hotmail.com>
Дата:
Hi list, How I can figure out the number of rows from the query? For example: String q1= "Select * from user where id=3"; PreparedStatement ps = conex.prepareStatement(q1); ResultSet rs = ps.executeQuery(); //Now how i can to know the number of rows from select? REgards, Ricardo _________________________________________________________________ MSN Fotos: la forma más fácil de compartir e imprimir fotos. http://photos.msn.es/support/worldwide.aspx
Re: numrows
От:
Dave Cramer <Dave@micro-automation.net>
Дата:
Ricardo, There's no way after the fact other than counting them, ie scrolling through them and keeping track. However for simple selects you can do select count(*), * from user where id=3 and count will contain the count. Dave On Thu, 2002-12-19 at 17:04, Ricardo Javier Aranibar León wrote: > Hi list, > > How I can figure out the number of rows from the query? > For example: > String q1= "Select * from user where id=3"; > PreparedStatement ps = conex.prepareStatement(q1); > ResultSet rs = ps.executeQuery(); > > //Now how i can to know the number of rows from select? > > REgards, > Ricardo > > > > > _________________________________________________________________ > MSN Fotos: la forma más fácil de compartir e imprimir fotos. > http://photos.msn.es/support/worldwide.aspx > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- Dave Cramer
Re: numrows
От:
Jeremy Buchmann <jeremy@wellsgaming.com>
Дата:
Or you could do: rs.last(); int numRows = rs.getRow(); rs.first(); That way you wouldn't have to scroll through the result set or run another query. Of course, you should error check rs.last() the same way you'd check rs.next(). --Jeremy On Thursday, December 19, 2002, at 03:59 PM, Dave Cramer wrote: > Ricardo, > > There's no way after the fact other than counting them, ie scrolling > through them and keeping track. > > However for simple selects you can do > > select count(*), * from user where id=3 > > and count will contain the count. > > Dave > On Thu, 2002-12-19 at 17:04, Ricardo Javier Aranibar León wrote: >> Hi list, >> >> How I can figure out the number of rows from the query? >> For example: >> String q1= "Select * from user where id=3"; >> PreparedStatement ps = conex.prepareStatement(q1); >> ResultSet rs = ps.executeQuery(); >> >> //Now how i can to know the number of rows from select? >> >> REgards, >> Ricardo >> >> >> >> >> _________________________________________________________________ >> MSN Fotos: la forma más fácil de compartir e imprimir fotos. >> http://photos.msn.es/support/worldwide.aspx >> >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to >> majordomo@postgresql.org) > -- > Dave Cramer > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >