# Database Discussions > IBM DB2 >  Avoid use of "low-values" predicate in query

## jfdutcher

Does anyone believe it is possible to duplicate the "practical effect" of the following query.......while removing the 
final line predicate -->:   "WHERE (Z.HP_ID > :ORDER-HP-ID)"  ?  ( :ORDER-HP-ID has been initiated with "low-values" as the 
cursor is intended to commence scrolling from the top  ......   we've been asked to remove the predicate under the view that it is
the basic reason for timeouts ........ due to causing the entire set of rows to be retrieved in response to the low-values.

EXEC SQL                                                    
  DECLARE FORWARD-CURSOR-A CURSOR FOR                       
    WITH  HP_ID_TABLE (HP_ID                                
          )  AS                                             
    (SELECT A.HP_ID FROM V401APFN_CUR  A                    
       WHERE  A.HP_ID  IN                                   
        (SELECT AA.HP_ID                                    
           FROM   T401APFN AA                               
          WHERE  AA.PFN_PRV_LA_NAME LIKE :WS-LAST-NAME)     
            AND  A.PFN_PRV_LA_NAME LIKE :WS-LAST-NAME       
    UNION                                                   
         SELECT A.HP_ID FROM V401ATXP_CUR  A                
          WHERE  A.HP_ID  IN                                
           (SELECT AA.HP_ID                                 
             FROM   T401ATXP AA                             
            WHERE  AA.HP_BUS_NAME LIKE :WS-BUSINESS-NAME)   
              AND  A.HP_BUS_NAME LIKE :WS-BUSINESS-NAME)    
    SELECT Z.HP_ID                                          
         , Z.EDC_CRD_DEG_CODE                               
         , Z.HP_ADDR_STR_ADDR                               
         , Z.HP_ADD_INF_ADDR                                
         , Z.ZIP_LOC_CY_ADDR                                
                                           S
         , Z.ZIP_LOC_CY_ADDR                
         , Z.POL_RGN_CODE                   
         , Z.MN_ZIP_ADDR                    
         , Z.ZIP_SUF_ADDR                   
         , Z.HP_BUS_NAME                    
         , Z.PFN_PRV_LA_NAME                
         , Z.PFN_PRV_FST_NAME               
         , Z.PFN_PRV_MID_NAME               
         , Z.PRV_PRE_TTL_NAME               
         , Z.PRV_SUC_TTL_NAME               
         , Z.HP_ADDR_MNE_CODE               
         , Z.NAME_TYP_CODE                  
         , Z.NAME_PIT_FMT_CODE              
         , Z.HP_FGN_LN_1_ADDR               
         , Z.HP_FGN_CY_ADDR                 
         , Z.HP_FGN_PT_DLV_ADDR             
         , Z.COY_CODE                       
         , Z.SPL_TYP_CODE                   
         , Z.HP_ADDR_TKN                    
    FROM                                    
   (SELECT A.HP_ID                          
         , '     '      AS EDC_CRD_DEG_CODE 
                                           SCROLL ===> CSR  
         , '     '      AS EDC_CRD_DEG_CODE                 
         , C.HP_ADDR_STR_ADDR                               
         , C.HP_ADD_INF_ADDR                                
         , C.ZIP_LOC_CY_ADDR                                
         , C.POL_RGN_CODE                                   
         , C.MN_ZIP_ADDR                                    
         , C.ZIP_SUF_ADDR                                   
         , A.HP_BUS_NAME                                    
         , '    '  AS PFN_PRV_LA_NAME                       
         , '               '   AS PFN_PRV_FST_NAME          
         , '          '        AS PFN_PRV_MID_NAME          
         , '     '             AS PRV_PRE_TTL_NAME          
         , '    '              AS PRV_SUC_TTL_NAME          
         , C.HP_ADDR_MNE_CODE                               
         , A.NAME_TYP_CODE                                  
         , ' ' AS NAME_PIT_FMT_CODE                         
         , C.HP_FGN_LN_1_ADDR                               
         , C.HP_FGN_CY_ADDR                                 
         , C.HP_FGN_PT_DLV_ADDR                             
         , C.COY_CODE                                       
         , G.SPL_TYP_CODE                                   
         , C.HP_ADDR_TKN                                    
          FROM   V401ATXP_CUR A                     
       , V401AHCP_CUR B                     
       , V401AHPA_CUR C                     
       , V401ASPE_CUR G                     
     WHERE A.HP_ID = C.HP_ID                
       AND A.HP_ID = B.HP_ID                
       AND A.HP_ID = G.HP_ID                
       AND A.HP_ID  IN                      
               (SELECT AA.HP_ID             
                FROM   HP_ID_TABLE  AA)     
     AND B.HP_ID  IN                        
             (SELECT BB.HP_ID               
              FROM   HP_ID_TABLE  BB)       
     AND C.HP_ID  IN                        
             (SELECT CC.HP_ID               
              FROM   HP_ID_TABLE  CC)       
     AND G.HP_ID  IN                        
             (SELECT GG.HP_ID               
              FROM   HP_ID_TABLE  GG)       
     AND B.PRV_GRP_PRA_IND = 'Y'            
     AND G.INF_IPT_CODE = 'P'               
     AND G.PRV_SPL_CNL_DATE= '9999-12-31'                   
     AND C.ADDR_TYP_CODE = 'B'                              
     AND C.MN_ZIP_ADDR = :SCOPE-FIELDS.SCOPE-MVA-ZIP-C      

     UNION ALL                                              

     SELECT A.HP_ID                                         
          , H.EDC_CRD_DEG_CODE                              
          , C.HP_ADDR_STR_ADDR                              
          , C.HP_ADD_INF_ADDR                               
          , C.ZIP_LOC_CY_ADDR                               
          , C.POL_RGN_CODE                                  
          , C.MN_ZIP_ADDR                                   
          , C.ZIP_SUF_ADDR                                  
          , ' ' AS HP_BUS_NAME                              
          , E.PFN_PRV_LA_NAME                               
          , E.PFN_PRV_FST_NAME                              
          , E.PFN_PRV_MID_NAME                              
          , E.PRV_PRE_TTL_NAME                              
          , E.PRV_SUC_TTL_NAME                              
          , C.HP_ADDR_MNE_CODE                              
          , C.HP_ADDR_MNE_CODE                              
          , 'P' AS NAME_TYP_CODE                            
          , E.NAME_PIT_FMT_CODE                             
          , C.HP_FGN_LN_1_ADDR                              
          , C.HP_FGN_CY_ADDR                                
          , C.HP_FGN_PT_DLV_ADDR                            
          , C.COY_CODE                                      
          , G.SPL_TYP_CODE                                  
          , C.HP_ADDR_TKN                                   
     FROM   V401ATXP_CUR A                                  
          , V401AHCP_CUR B                                  
          , V401AHPA_CUR C                                  
          , V401APFN_CUR E                                  
          , V401ASPE_CUR G                                  
          , V401ADEG_CUR H                                  
        WHERE A.HP_ID = C.HP_ID                             
          AND A.HP_ID = B.HP_ID                             
          AND A.HP_ID = E.HP_ID                             
          AND A.HP_ID = G.HP_ID                             
          AND A.HP_ID = H.HP_ID                             
          AND A.HP_ID  IN                                   
                (SELECT AA.HP_ID                            
                 FROM   HP_ID_TABLE  AA)                    
          AND B.HP_ID  IN                                   
                (SELECT BB.HP_ID                            
                 FROM   HP_ID_TABLE  BB)                    
          AND C.HP_ID  IN                                   
                (SELECT CC.HP_ID                            
                 FROM   HP_ID_TABLE  CC)                    
          AND G.HP_ID  IN                                   
                (SELECT GG.HP_ID                            
                 FROM   HP_ID_TABLE  GG)                    
          AND E.HP_ID  IN                                   
                (SELECT EE.HP_ID                            
                 FROM   HP_ID_TABLE  EE)                    
          AND H.HP_ID  IN                                   
                  (SELECT HH.HP_ID                          
                   FROM   HP_ID_TABLE  HH)                  
          AND B.PRV_GRP_PRA_IND = 'N'                       
          AND G.INF_IPT_CODE = 'P'                          
          AND G.PRV_SPL_CNL_DATE= '9999-12-31'              
          AND C.ADDR_TYP_CODE = 'B'                         
          AND C.MN_ZIP_ADDR = :SCOPE-FIELDS.SCOPE-MVA-ZIP-C 
          AND C.MN_ZIP_ADDR = :SCOPE-FIELDS.SCO
       ) AS Z                                  
   WHERE (Z.HP_ID > :ORDER-HP-ID)          <-------------       
        ORDER BY HP_ID       ASC               
        FOR FETCH ONLY                         
        WITH UR                                
END-EXEC

----------

