Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / April 2008

Tip: Looking for answers? Try searching our database.

Count items in reslutset?

Thread view: 
WJ - 24 Apr 2008 18:52 GMT
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
Donkey Hot - 24 Apr 2008 19:07 GMT
WJ <wjz@wirehub.nl> wrote in news:e1c38$4810c8fc$3ec2c5b8$6409
@news.chello.nl:

> Hi all,
>
[quoted text clipped - 6 lines]
> Thanx,
> WJ

ResultSet rs ;
int count ;

....

count = rs.getInt(1) ;
Uwe Seimet - 24 Apr 2008 19:50 GMT
> 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.

Signature

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

Lew - 25 Apr 2008 00:40 GMT
>> ResultSet rs ;
>> int count ;
[quoted text clipped - 7 lines]
> 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.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.