× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Dan,

You'll need a scrollable cursor and when you need to position to previous 
records, you'd use FETCH RELATIVE n where n is the number of records on your 
subfile. n will need to be a negative number to go backwards. That will get the 
first record you need to load and then you'd just use a regular FETCH (or FETCH 
NEXT if you want -- they both mean the same thing) to get the rest of your 
records. The SQL Programming Guide has examples of doing this.

The "position to" will be the hard part since I'm going to guess that the user 
will enter something that's meaningful to them (such as an order or part 
number) and not the record number in your cursor. You may need to read through 
all the rows in the cursor to do this. Of course, if the field just means "skip 
ahead n records", then FETCH RELATIVE will work just fine for that too.

Matt

-----Original Message-----
From: Dan Bale [mailto:dbale@xxxxxxxxxxxxx]
Sent: Wednesday, October 13, 2004 11:10 AM
To: RPG400-L@xxxxxxxxxxxx
Subject: subfile page up & down using embedded SQL 


Esteemed listers:

I thought I had seen references to this before, but I am coming up empty
searching the archives both from the search page and from google.

I have a subfile inquiry app that currently loads the subfile a page at a
time via SETLL and a READ loop.  Paging works as expected; Page Down gets
the next set of records following the one appearing at the bottom of the
current page, and Page Up gets the set of records prior to the one appearing
at the top of the current page.  There is also a "Position To:" entry at the
top that invokes the SETLL.

I am attempting to introduce new features that require SQL FETCH to replace
the SETLL, READ, and READP operations.  (Note, FWIW, this is _not_ READE or
READPE.)  Well, not really sure how to replace the SETLL part.  I think I
understand that I would use FETCH NEXT to emulate READ and FETCH PREVIOUS to
emulate READP.

I think I would know how to handle the Page Down routine --- just do another
iteration of FETCH NEXT for a new page.  But the Page Up routine, this one's
a bugger.  Since I load a subfile page from top to bottom, the SQL cursor is
positioned at the record that appears at the bottom of the subfile.  In
normal RPG I/O, when a Page Up is requested, I would just SETLL using the
first subfile record, and READP from there.  I'm just not getting how I
would accomplish this using embedded SQL.

And if someone has a template that shows how to code a inquiry-only subfile
using SQL and is willing to share it, all the better.

FWIW, References I've found thus far:
iSeriesNetwork: Paul Conte's "SQL Crib Sheet for RPG Programmers", March
2000, article #3326
David Morris: http://archive.midrange.com/midrange-l/199911/msg01499.html

tia,
db

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.