|
OK, no one make fun of me. SQL and me are not close friends at all. Would this work for you? Can you define your cursor as 10 records long? Then each fetch would get 10 records, or however many are left in the file. --------------------------------------------------------- Booth Martin http://www.MartinVT.com Booth@xxxxxxxxxxxx --------------------------------------------------------- -------Original Message------- From: RPG programming on the AS400 / iSeries Date: Thursday, May 15, 2003 8:47:37 AM To: RPG programming on the AS400 / iSeries Subject: RE: Select Row Steve, I saw your post almost right after I sent mine (it takes forever for my e-mails to make the round trip for some reason) and you're right, the fetch xx rows does work on V5R1. Thanks for sharing that, I'm sure it will come in handy. As for the RRN trick, I didn't mean to say it doesn't work at all, I meant to say it isn't all that useful for selecting x number of rows on real world files. For example, let's say you try your example where CUNBR > 9000 and CUNBR < 10000 and RRN < 10. Chances are, none of these records will have a RRN less than 10 so you get no data. Matt -----Original Message----- From: Steve Landess [mailto:steve_landess@xxxxxxxxxxx] Sent: Thursday, May 15, 2003 9:05 AM To: RPG programming on the AS400 / iSeries Subject: Re: Select Row >Matt wrote: > Ren, > Prior to V5R2 (I think this is part of V5R2), you can't do this with a SELECT statement. The relative record number idea will only work if there are no deleted records and you don't use a where clause which, IMHO, makes this trick all but useless in most cases. Matt: I don't know about prior releases, but both of the following SQL statements work on V5R1: select *from cusmst fetch first 2 rows only SELECT statement run complete. SELECT * FROM cusmst WHERE CUNBR < 100 AND rrn(cusmst) < 10 SELECT statement run complete. Steve Landess Austin, Texas (512) 423-0935
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.