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



One way that I avoid this whole issue is to put the results into a user
space mapped to a multiple occurrence data structure. 

This not only solves the problem of loops because all the records are
read in one I/O but it increases performance significantly because all
the records are read at once and written to the user space at the
database level. IBM recommends where possible to use arrays. 

Then you just read the multiple occurrence data structure in a loop. 
Note this code use Qualified Data Structure so only works on V5R3M0 up.
Remove the qualification and it runs on anything. 

Also, I am using my User Space API's. Again someone wants to use them,
send me an e-mail at alan0307d@xxxxxxxxxxxx The just wrap up all the
complexity of using User Spaces. 

    d cUserSpaceName...

    d                 c                   'TESTJVA3'

    d cUserSpaceLibrary...

    d                 c                   'QTEMP'

    d cText...

    d                 c                   'Hold records for processing.'

    d dsRow...                                               
    d                 ds                  Occurs(32766)       
    d                                     Based(ptrRow)
    d                                     Qualified    
    d  ADDR1...                                             
    d                               40a                       
    d  ADDR2...                                             
    d                               40a                       
    d  CITY...                                              
    d                               15a                       
    d  STATE...                                             
    d                                3a                       
    d  ZIP...                                               
    d                               10a                       
                                                              
    d RowCount...                                           
    d                 s                   Like(StdInt)        
    d                                     Inz(0)      
    d x...
    d                 s                   Like(StdInt)      
     /Free                                                
                                                          
      ptrRow = CreateUserSpace(cUserSpaceName      :   
                               cUserSpaceLibrary   :   
                               %Size(dsRow) * 1000:   
                               cText               :   
                               32                  );  
                                                          
      Exsr srSQL01; // Load all records into a user space.
      If SqlCod <> 0;                                     
       Return;                                            
      EndIf;                           
                     
      For x = 1 to RowCount;        
        %Occur(dsRow) = x;

      // Your code here to process results. 

      EndFor;

      /End-Free                                   
     csr   srSQL01       Begsr                    
                                                  
     c/Exec Sql                                   
     c+  Declare GasList Cursor For               
     c+    Select GSLADD1,                        
     c+           GSLADD2,                        
     c+           GSLCITY,                        
     c+           GSLSTATE,                       
     c+           GSLZIP                          
     c+      From RTGASSP                         
     c+      Where Length(Trim(GSLZIP)) = 5       
     c/End-Exec                                   
                                                  
     c/Exec Sql                                   
     c+  Open GasList                             
     c/End-Exec                                   

     c                   If        SqlCod <> 0    
     c                   LeaveSr                  
     c                   EndIf   
                 
     c/Exec Sql

     c+  Fetch From GasList For 32766 Rows Into :dsRow

     c/End-Exec 
                                                           
     c                   If        SqlCod <> 0

     c                   LeaveSr

     c                   EndIf

 

     c                   Eval      RowCount = SQLERRD(3)

                                                        
     c/Exec Sql
     c+  Close GasList
     c/End-Exec
                    
     csr                 Endsr

     p                 e

      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
      * CreateUserSpace

      *   Create User Space to hold records.

      *   Input     - User Space Name.

      *               User Space Library.

      *               Size of User Space.

      *               Pages to transfer at a time.

      *   Out       - None
*   Returns   - PointerToUserSpace.                                     
      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -   
     p CreateUserSpace...

     p                 b

     d                 pi                  Like(StdPtr)

     d   InUserSpaceName...

     d                                     Like(StdNam)

     d                                     Value

     d   InUserSpaceLibrary...

     d                                     Like(StdNam)

     d                                     Value

     d   InUserSpaceSize...

     d                                     Like(StdInt)

     d                                     Value

     d   InText...

     d                                     Like(StdTxt)

     d                                     Value

     d   InTransferPages...

     d                                     Like(StdInt)

     d                                     Value

                                                                
      /copy *libl/qsrcf,xvuspc_pr                           
                                                                
      /Free                                                     
                                                                
         USPC_CreateUserSpace(InUserSpaceName   :               
                              InUserSpaceLibrary:               
                              InUserSpaceSize   :               
                              cTrue             :               
                              InText            :               
                              '*ALL'            :               
                              '*YES'            :               
                              InTransferPages   :               
                              cTrue             );              
                                                                
         Return USPC_GetPointerToUserSpace(InUserSpaceName   :  
                                           InUserSpaceLibrary); 
                                                                
      /End-Free                                                 
     p                 e                                        


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.