× 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.



Most of my problems stemmed from passing EOF and attempting to go back the
other way.  I kept getting a one-off page roll.
SFLPAGE1 = 15 in this case
*IN98 = conditioning for allowing page-down and SFLMORE()
*IN94 = conditioning for allowing page-up 
Even though the sub file is not actually set as a page-at-at-time, we load
it as though it were.  The DDS is from a template that we have around here
and I am not suggesting that this is the way it must be done.  It works well
with file index access, too.  I hope this is enough.

...     ...
     C* F5 Refresh screen                           
     C                   WHEN      *INKE            
     C                   EXSR      SETCURPAGE       
     C                   EXSR      SQLFETCH         
     C                   EVAL      RELOAD = 'Y'     
...     ...
...     ...
     C* Page Up pressed : Set pointers and reload subfile  
     C                   WHEN      *IN34                   
     C                   EVAL      BEGIN = 1               
     C                   EXSR      SETPAGEUP               
     C                   EXSR      SQLFETCH                
     C                   EVAL      RELOAD = 'Y'            
     C* Page Down pressed : Load next page of records      
     C                   WHEN      *IN33                   
     C                   EVAL      BEGIN = 1               
     C                   EVAL      *IN94 = *OFF            
     C                   EXSR      SQLFETCH                
     C                   EVAL      RELOAD = 'Y'            
     C                   OTHER                             
...     ...
...     ...
     C                   ENDSL                 
     C                   ENDIF                 
     C                   ENDIF                 
     C* Reload subfile if necessary            
     C     REDISPLAY     TAG                   
     C                   IF        RELOAD = 'Y'
     C                   EXSR      SFLLOAD1    
     C                   ENDIF                 


    C     SETPAGEUP     BEGSR                                     
    C*                                                            
     * When paging up from last page, page up one less record.    
    C                   IF        *IN98 = *ON                     
    C                   EVAL      PUROWS = 0-(SFLPAGE1+ACTPGSZ+1) 
    C                   ELSE                                      
    C                   EVAL      PUROWS = 0-(SFLPAGE1+ACTPGSZ)   
    C                   ENDIF                                     
    C/EXEC SQL                                                    
    C+ FETCH RELATIVE :PUROWS  FROM SQLCSR                        
    C/END-EXEC                                                    
    C* Reached beyond top of data set                             
    C                   IF        SQLSTT = '02000'                
    C                   EVAL      *IN94 = *ON                     
    C                   ELSE                                      
    C                   EVAL      *IN94 = *OFF                    
    C                   ENDIF                                     
    C*                                                            
    C                   ENDSR                                     


     CSR   SQLFETCH      BEGSR

     C                   RESET                   RSDATA

     C/EXEC SQL

     C+ FETCH NEXT FROM SQLCSR FOR :SFLPAGE1 ROWS INTO :RSDATA

     C/END-EXEC

      * STATE CODE 02000 MEANS FETCHED BEYOND END OF

      *   AVAILABLE RECORD SET IN CURSOR OR AN EOF.

     C                   IF        SQLSTT = '02000'

     C                   EVAL      *IN98 = *ON

     C                   EVAL      ACTPGSZ = *ZEROS

     C                   ELSE

     C                   EVAL      *IN98 = *OFF

     C                   EVAL      ACTPGSZ = SQLER3

     C                   ENDIF

      * check to see if we are at EOF but last record was last record to

      *   fit on one page.

     C                   IF        *IN98 = *OFF

     C/EXEC SQL

     C+ FETCH NEXT FROM SQLCSR

     C/END-EXEC

     C                   IF        SQLSTT = '02000'
EOF 
     C                   EVAL      *IN98 = *ON

      * EOF position to just after last record

     C/EXEC SQL                                      
     C+ FETCH AFTER FROM SQLCSR                      
     C/END-EXEC                                      
     C                   ELSE                        
      * not EOF, position to record just on.         
     C/EXEC SQL                                      
     C+ FETCH PRIOR FROM SQLCSR                      
     C/END-EXEC                                      
     C                   ENDIF                       
     C                   ENDIF                       
     CSR                 ENDSR                       


     CSR   SETCURPAGE    BEGSR                                   
     C                   IF        *IN98 = *ON                   
     C                   EVAL      PUROWS = 0-(ACTPGSZ+1-POSFLD) 
     C                   ELSE                                    
     C                   EVAL      PUROWS = 0-(ACTPGSZ-POSFLD)   
     C                   ENDIF                                   
     C                   EVAL      POSFLD = 0                    
     C/EXEC SQL                                                  
     C+ FETCH RELATIVE :PUROWS FROM SQLCSR                       
     C/END-EXEC                                                  
     C* Reached beyond top of data set                           
     C                   IF        SQLSTT = '02000'              
     C                   EVAL      *IN94 = *ON                   
     C                   ELSEIF    SQLSTT = '22006'              
     C                   EVAL      *IN94 = *ON                   
     C/EXEC SQL                                                  
     C+ FETCH BEFORE FROM SQLCSR                                 
     C/END-EXEC                                                  
     C                   ELSE                                    
     C                   EVAL      *IN94 = *OFF                  
     C                   ENDIF                                   
     CSR                 ENDSR                                

   
     A          R SFLCONTROL                SFLCTL(SUBFILE)         
     A                                      SFLSIZ(0017)            
     A                                      SFLPAG(0015)            
     A N98                                  PAGEDOWN(33)            
     A N94                                  PAGEUP(34)              
     A  98                                  SFLEND(*MORE)
Thank you,
Matt Tyler
WinCo Foods, Inc
mattt@xxxxxxxxxxxxxx

-----Original Message-----
From: Dan Bale [mailto:dbale@xxxxxxxxxxxxx]
Sent: Wednesday, September 15, 2004 1:36 p
To: RPG programming on the AS400 / iSeries
Subject: RE: different iterations of SQL run statements in same program

> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx / Tyler, Matt
> Sent: Wednesday, September 15, 2004 2:45 PM
>
> Dan,
>       Curious, how are you presenting the data set to the user(s),
> Page-at-a-time, full-load, other?  I have a couple of page-at-a-time SQL
> programs that took me a while to figure out the relative cursor
> positioning for paging.

Funny you should ask.  I got sidetracked with another project, but that was
my next task, setting this up for page-at-a-time.  I've only ever fetched a
record-at-a-time in a Dou SQLCOD<>0 loop.  If you have sample code you'd be
willing to share, I'd be happy to learn from it.

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.