Re: numrows - Mailing list pgsql-jdbc

From Jeremy Buchmann
Subject Re: numrows
Date
Msg-id 738BF76C-13B0-11D7-84CC-000502E740BA@wellsgaming.com
Whole thread Raw
In response to Re: numrows  (Dave Cramer <Dave@micro-automation.net>)
List pgsql-jdbc
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 <Dave@micro-automation.net>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: numrows
Next
From: Noel
Date:
Subject: Re: error when using move, any suggestions?