Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.databases > #27 > unrolled thread

Count items in reslutset?

Started by"WJ" <wj@THRWHITE.remove-dii-this>
First post2011-04-27 15:21 +0000
Last post2011-04-27 15:21 +0000
Articles 4 — 4 participants

Back to article view | Back to comp.lang.java.databases


Contents

  Count items in reslutset? "WJ" <wj@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
    Re: Count items in reslut "Donkey Hot" <donkey.hot@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
      Re: Count items in reslut "Uwe Seimet" <uwe.seimet@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
        Re: Count items in reslut "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000

#27 — Count items in reslutset?

From"WJ" <wj@THRWHITE.remove-dii-this>
Date2011-04-27 15:21 +0000
SubjectCount items in reslutset?
Message-ID<e1c38$4810c8fc$3ec2c5b8$6409@news.chello.nl>
  To: comp.lang.java.databases
Hi all,

Is it possible to get the number of rows in a resultset using SQL?

If I execute a statement like: SELECT COUNT(*) FROM table1 WHERE ID=12,

I dont know how to assign the result to an integer...

Thanx,
WJ

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#28 — Re: Count items in reslut

From"Donkey Hot" <donkey.hot@THRWHITE.remove-dii-this>
Date2011-04-27 15:21 +0000
SubjectRe: Count items in reslut
Message-ID<Xns9A8ADA910449FSH15SGybs1ysmajw54s5@194.100.2.89>
In reply to#27
  To: comp.lang.java.databases
WJ <wjz@wirehub.nl> wrote in news:e1c38$4810c8fc$3ec2c5b8$6409
@news.chello.nl:

> Hi all,
> 
> Is it possible to get the number of rows in a resultset using SQL?
> 
> If I execute a statement like: SELECT COUNT(*) FROM table1 WHERE ID=12,
> 
> I dont know how to assign the result to an integer...
> 
> Thanx,
> WJ
> 

ResultSet rs ;
int count ;

....

count = rs.getInt(1) ;

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#29 — Re: Count items in reslut

From"Uwe Seimet" <uwe.seimet@THRWHITE.remove-dii-this>
Date2011-04-27 15:21 +0000
SubjectRe: Count items in reslut
Message-ID<67c33oF2nukhoU1@mid.individual.net>
In reply to#28
  To: comp.lang.java.databases
Donkey Hot wrote:

> ResultSet rs ;
> int count ;
> 
> ....
> 
> count = rs.getInt(1) ;

One should probably add that this row count cannot be used to determine 
the number of rows of a subsequent SELECT statement that selects actual 
row data (not just the count) from the same table. Between the two 
SELECT statements the number of rows may have changed.

-- 
-----------------------------------------------------------------------
   Dr. Uwe Seimet                           http://www.linkbylink.net/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#33 — Re: Count items in reslut

From"Lew" <lew@THRWHITE.remove-dii-this>
Date2011-04-27 15:21 +0000
SubjectRe: Count items in reslut
Message-ID<4dWdnWLXD_fCh4zVnZ2dnUVZ_ovinZ2d@comcast.com>
In reply to#29
  To: comp.lang.java.databases
Uwe Seimet wrote:
> Donkey Hot wrote:
> 
>> ResultSet rs ;
>> int count ;
>>
>> ....
>>
>> count = rs.getInt(1) ;
> 
> One should probably add that this row count cannot be used to determine 
> the number of rows of a subsequent SELECT statement that selects actual 
> row data (not just the count) from the same table. Between the two 
> SELECT statements the number of rows may have changed.

Depending on the semantics of the transaction type in which you wrap the 
multiple statements.

-- 
Lew

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.databases


csiph-web