There are established patterns to do your paging which might be better but a 
very simple traversal through a selection by 100 could work like this. You can 
manipulate batchPos to move forward and back through the list.

Program
   RowBatchSize = 100
   quitCondition = @false
   selectStatement = 'SELECT PRODUCTS BY PROD.NAME'
   execute selectStatement capturing capText returning maxList
   readlist selectList then
      for batchPos = 1 to maxList step rowBatchSize until quitCondition
            pageBatch  = field(selectList,@am,batchPos,rowBatchSize)
            ** do some paging stuff here with pageBatch
            gosub DoSomePagingStuff:
      next batchPos
   end

cheers,
Stuart Boydell 


-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Adrian Halid
Sent: Friday, 19 February 2010 12:45
To: U2 Users List
Subject: Re: [U2] TOP/LIMIT Equivalent?

If I have a file of 100,000 products and I want to page them in a list of 100 
on my website sorted by product name in attribute 1.

SELECT PRODUCTS BY A1

This would return me all 100,000 products.

So what would be my query when the website loads and I only want the 1st 100 by 
product name.

Then the user would click the "Next" button to display the 2nd 100 (101, 200). 
What would be my query then?

Would I always have to perform the full select and return 100,000 records and 
then loop through and only show records 101 to 200.

Isn't there a better way so that you only return the 100 records you want to 
view.



Regards

Adrian Halid
Senior Analyst/Programmer
 
IT Vision Australia Pty Ltd (ABN: 34 309 336 904)
PO Box 881, Canning Bridge WA 6153
Level 3, Kirin Centre, 15 Ogilvie Road, Applecross, WA, 6153
P:  (08) 9315 7000      F:  (08) 9315 7088
E:  adrian.ha...@itvision.com.au        W: http://www.itvision.com.au
    
___________________________________________________________  
                          
NOTICE : This e-mail and any attachments are intended for the addressee(s) only 
and may
contain confidential or privileged material. Any unauthorised review, use, 
alteration,
disclosure or distribution of this e-mail (including any attachments) by an 
unintended recipient
is prohibited. If you are not the intended recipient please contact the sender 
as soon as
possible by return e-mail and then delete both messages.
___________________________________________________________



-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dan Fitzgerald
Sent: Friday, 19 February 2010 9:29 AM
To: 'U2 Users List'
Subject: Re: [U2] TOP/LIMIT Equivalent?

You could save the list, and edit it. But, really, there will be no logical
relationship between these records. The 1st hundred is just as random as the
2nd or 3rd hundred, unless your modulus is an extremely ill-advised one. 

Again, they are hashed records. What we mean by this is that UV will take
your item id, extract a numeric equivalent from it (i.e., a238rs45 becomes
23845), then divides by the modulo (a simplification, but reasonably
illustrative for our purposes). It takes the resulting remainder (if your
modulus was 101, this will be 9), adds 1 (because you can have a remainder
of 0), and puts that record into group #10. Unless you know your precise
hashing algorithm (which was proprietary, last time I checked), you simply
don't know where the record will land. (OK, if you have sequential numeric
id's, and you use group.stat.detail to analyze the file, you might be able
to predict it, but whatever algorithm you cook up goes out the window if you
resize or change the file type, and that's a lot of unnecessary work,
anyway). If you want a random sample, use SAMPLE. If you need a logically
related group (the last 100 records added, for example), then you should
apply selection criteria (SSELECT FILE WITH TIMESTAMP GE xxxx BY-DSND
TIMESTAMP). The logic is in the data.

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Adrian Halid
Sent: Thursday, February 18, 2010 8:06 PM
To: U2 Users List
Subject: Re: [U2] TOP/LIMIT Equivalent?

But how would you get the 2nd 100 (101 - 200) and the 3rd 100 (301 to 400)
without writing a subroutine to do it?


Regards

Adrian Halid
Senior Analyst/Programmer
 
IT Vision Australia Pty Ltd (ABN: 34 309 336 904)
PO Box 881, Canning Bridge WA 6153
Level 3, Kirin Centre, 15 Ogilvie Road, Applecross, WA, 6153
P:  (08) 9315 7000      F:  (08) 9315 7088
E:  adrian.ha...@itvision.com.au        W: http://www.itvision.com.au
    
___________________________________________________________  
                          
NOTICE : This e-mail and any attachments are intended for the addressee(s)
only and may
contain confidential or privileged material. Any unauthorised review, use,
alteration,
disclosure or distribution of this e-mail (including any attachments) by an
unintended recipient
is prohibited. If you are not the intended recipient please contact the
sender as soon as
possible by return e-mail and then delete both messages.
___________________________________________________________



-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of fft2...@aol.com
Sent: Friday, 19 February 2010 4:55 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] TOP/LIMIT Equivalent?

In a message dated 2/18/2010 10:27:46 AM Pacific Standard Time, 
cla...@hme.com writes:


> You can sort first and then SAMPLE, too.>>

Caryl has the idea here if you really want the "Last" 100.
You can Sort BY-DSND which means "by descending" so if you want the last 
alphabetically or the last by ID or the last by some other field you can
sort 
on that and then Sample 100 ?  I've NEVER tried this.  Does it work?

If that doesn't work you can EXECUTE a sort by dsnd and then simply write a 
brief BASIC routine to pull off the "first" 100 of that list and output it!

Will "Where There's a Way there's a Will... or something" Johnson
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

******************************************************************************************************
This email message and any files transmitted with it are confidential and 
intended solely for the use of addressed recipient(s). If you have received 
this communication in error, please reply to this e-mail to notify the sender 
of its incorrect delivery and then delete it and your reply.  It is your 
responsibility to check this email and any attachments for viruses and defects 
before opening or sending them on. Spotless collects information about you to 
provide and market our services. For information about use, disclosure and 
access, see our privacy policy at http://www.spotless.com.au
Please consider our environment before printing this email.
******************************************************************************************************
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to