Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Row Count from the resultset

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-05-20 20:26:20.0Z
Pawan Desai Posted on 1997-05-06 17:22:48.0Z
Message-ID: <336F68E8.3F04@caribsurf.com>
Date: Tue, 06 May 1997 10:22:48 -0700
From: Pawan Desai <pdesai@caribsurf.com>
Reply-To: pdesai@caribsurf.com
Organization: TTSL
X-Mailer: Mozilla 3.0 (WinNT; I)
MIME-Version: 1.0
Subject: Row Count from the resultset
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 8
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:870
Article PK: 252622

Hi there

I am using JConnect. I would like to know whether there is any method
for getting the no. of rows retrived in a result set. I looked for all
the documentation and couldn't find one.

But there has to be one. May be I am missing something.

Please Help..
Regards
pawan.desai


David Clegg Posted on 1997-05-20 20:26:20.0Z
Message-ID: <338208EC.365FACEF@sybase.com>
Date: Tue, 20 May 1997 13:26:20 -0700
From: David Clegg <davec@sybase.com>
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i586)
MIME-Version: 1.0
To: pdesai@caribsurf.com
Subject: Re: Row Count from the resultset
References: <336F68E8.3F04@caribsurf.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 23
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:808
Article PK: 252559

No, there is no way to get the number of rows in a ResultSet through
JDBC. SQL is a set oriented language, and in general you don't know
how many rows there will be in a ResultSet until you've already
fetched them all (and counted along the way).
You could modify your query into a batch and get the information:

select count(*) from <your query>; select * from <your query again>

This would give you 2 result sets -- the first would have the #
rows, and the 2nd would be the one you are after. This method
is likely to cause the SQL Server to do twice as much work...

dave

> Hi there
>
> I am using JConnect. I would like to know whether there is any method
> for getting the no. of rows retrived in a result set. I looked for all
> the documentation and couldn't find one.
>
> But there has to be one. May be I am missing something.
>
> Please Help..
> Regards
> pawan.desai