Thanks for the replies.

I am not actually working on a project that needs to do paging. I was really 
just wonder how to do it best in case I need to do it in the future.

I thought there might be a different way instead of having to manage a list. 

I guess the main reason why you may not want to use a list is if new records 
are continually being added or deleted. 

Keeping a saved list does not guarantee that all the records in that list are 
still valid. New records could of been created that should be included and old 
records may be deleted that should not exist in the list anymore.

This would mean you would need to continually re perform your search to update 
your search list.

Plus I thought you would have better performance if you could perform a search 
an only bring back 100 records instead of 1000000 each time.


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 Oaks, Harold
Sent: Saturday, 20 February 2010 1:52 AM
To: U2 Users List
Subject: Re: [U2] TOP/LIMIT Equivalent?

Adrian:

Here's a dumb little solution that might work for you if you can run a VOC 
paragraph (I don't know how your interface to the web application is set up).

We have Universe.  I make use of the standard line editor ED which I think 
everybody has.

In the VOC file create the two paragraphs PREGET and GETRECS:

PREGET is these 3 lines:
PA
SELECT PRODUCTS BY A1
SAVE.LIST LIST1

GETRECS is these 9 lines:
PA
DELETE.LIST LIST2
EDIT.LIST LIST2
DATA LOAD LIST1
DATA <<I2,FROMLINE>>
DATA <<I3,TOLINE>>
DATA FILE
GET.LIST LIST2
LIST PRODUCTS REQUIRE.SELECT

First run PREGET.  This selects all the records sorted as you wish and creates 
the saved list LIST1.  You only run this once.

Now, for each selection range of records desired, you run GETRECS with 2 
parameters, fromline and toline.  For example:
GETRECS 1 100         will display the first 100 records
GETRECS 700 725       will display the 700th thru 725th records

Of course the final line "LIST PRODUCTS REQUIRE.SELECT" would display output on 
the terminal.  You'll be doing something else to make the data you wish appear 
on the website, perhaps using LIST2 as your source for records IDs.  Note that 
REQUIRE.SELECT is necessary in my LIST command to ensure we don't display the 
entire file if LIST2 is empty.  

I have a file with about 325000 records.  Running PREGET took about 12 seconds. 
 OK, that's a while. But after that, each run of GETRECS was very quick.  Even 
this command:
GETRECS 300001 300100 
took about 1/3 second to start displaying.

Harold Oaks
Sr. Analyst/Programmer
Clark County WA


-----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 5:45 PM
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
_______________________________________________
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

Reply via email to