Re: Getting limited number of rows on a table

From: Ward Mullins <ward_at_thoughtinc.com>
Date: 1998/06/25
Message-ID: <3592DDDB.299CD06_at_thoughtinc.com>#1/1


If you're using JDBC you can also limit the rows by the following method call in your JDBC Statement object.

 stmt.setMaxRows(10);

Hope that helps!

Just my $.02

Ward Mullins
THOUGHT Inc.
ward_at_thoughtinc.com
http:///www.thoughtinc.com

avaneesh.arora wrote:

> Hi All,
>
> Thanks for your replies.
>
> However, for some reason, the query does not seem to be working correctly
> for
> my table with a primary key consisting of 3 columns.
>
> This is what I have :
>
> 1 select aa1.accessid, aa1.alarmindex, aa1.alarmseqnum
> 2* FROM ALARM_TABLE aa1
>
> ACCESSID ALARMINDEX ALARMSEQNUM
> ------------ ---------------- -----------
> 100 2 1
> 100 3 2
> 100 2 3
> 100 2 4
> 4 2 5
> 4 3 6
> 5 2 7
> 5 2 8
> 105 2 9
> 105 3 10
> 105 2 11
> 105 2 12
> 103 2 13
> 103 2 14
>
> 14 rows selected.
>
> 1 select aa1.accessid, aa1.alarmindex, aa1.alarmseqnum
> 2 FROM ALARM_TABLE aa1
> 3 where 10 > (select count(*) from ALARM_TABLE aa2
> 4 where aa2.accessid <= aa1.accessid
> 5 and aa2.alarmindex <= aa1.alarmindex
> 6 and aa2.alarmseqnum <= aa1.alarmseqnum)
> 7* order by aa1.accessid asc, aa1.alarmindex asc, aa1.alarmseqnum asc
>
> ACCESSID ALARMINDEX ALARMSEQNUM
> ------------ ---------------- -----------
> 4 2 5
> 4 3 6
> 5 2 7
> 5 2 8
> 100 2 1
> 100 2 3
> 100 2 4
> 100 3 2
> 103 2 13
> 103 2 14
> 105 2 9
> 105 2 11
> 105 2 12
>
> 13 rows selected.
>
> Why do I get 13 rows when I am limiting the number to 10 only ?
> Also how do I get next 10 (or previous 10 at a later point) ?
>
> Any solutions will be appreciated.
>
> Thanks,
> Avaneesh
Received on Thu Jun 25 1998 - 00:00:00 CEST

Original text of this message