Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Form a query using TOP and fetch next Records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-03, 08:13
ravi_zee ravi_zee is offline
Registered User
 
Join Date: Sep 2003
Posts: 15
Question Form a query using TOP and fetch next Records

Hi,
I have an INI file, contans a fiel with "RestrictedRead =100"
I am reading the INI file in my Java code and getting this restrictd value and building a query dynamically for further processsing as...

sSQL = sSQL + " TOP " + getRestrictReadValue() + " ";

PROBLEM

If I have 10000 records to be processed, as of now it is reading only 100 records.But I want after 100 records completed it should fetch next 100 and continue till EOF(10000) records...

Can anyone help me how to succeed this and how to form a query for this scenario.

Matter very urgent

Cheers
Ravi
Reply With Quote
  #2 (permalink)  
Old 12-05-03, 09:03
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
I dont know the meaning of "TOP" in this context.

If you will retrive all records into a single result set then use the following method. However if you only want to return 100 per result set then the second option will work, although the first is clearly faster and more efficent.

From 1.4 -
"boolean absolute(int row)
Moves the cursor to the given row number in this ResultSet object"

This is ideal for your problem and its also faster than the SQL query, simply set row to row + limit.

Here is the SQL query alternative anyway,

The final row of ResultSet will contain the last rownum returned. Repeat this procedure until EOF is reached.

X = X + (rownum from final row) ' set X to 0 for first call
limit = 100

Query,

select columns
from
(
select *
from table
minus
select *
from table
where rownum <= X)
where rownum <= limit;
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456 : 12-06-03 at 22:19.
Reply With Quote
  #3 (permalink)  
Old 12-05-03, 10:13
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
Update -
A solution to your problem using the ResultSet absolute method has been included in my previous reply. It's the efficent solution. If you do need to use multiple instances of ResultSet, then perhaps some PL/SQL in conjunction with a fast query.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456 : 12-05-03 at 10:23.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On