mgo
OS/400 Edition
Volume 2, Number 55 -- July 24, 2002

Did OPNQRYF Retrieve Records?


Hey, Ted:

Here is a tip you may want to print. Sometimes I need to find out if an Open Query File (OPNQRYF) selection contains any records. For instance, I may want certain programs to run only if OPNQRYF did not select any records. I run the following commands after OPNQRYF runs:

/*  Copy 1 record for testing purposes  */                            
CPYFRMQRYF FROMOPNID( IVRPTHDQ ) +
   TOFILE( QTEMP/@DUMMY )  
   MBROPT( *REPLACE ) +
   CRTFILE( *YES ) +
   NBRRCDS( 1 )

RTVMBRD    FILE( QTEMP/@DUMMY ) +
   NBRCURRCD( &RCNT )       
                                                                      
IF       ( &RCNT *GT 0 ) THEN( DO )                      
   POSDBF     IVRPTHDQ  *Start        
   CALL       Program
ENDDO


Of course, this code won't tell you how many records were retrieved, but knowing that at least one record was retrieved or that none were retrieved is sufficient for the vast majority of the cases.

-- Mark


Thanks for the tip, Mark. This is the best solution I've ever found, and it's the one I've used through the years.

-- Ted




Sponsored By
TRAMENCO

The Training and Mentoring Company (Tramenco) is dedicated to just one thing: Advancing your career by giving you the skills you need to solve real-world business problems.

Choose from a menu of training options to fit your needs: onsite seminars, public seminars, mentoring, consulting, books, CBTs, and Web-based training.

For more information about Tramenco's career enhancing opportunities, call (800)421-8031 or go to www.tramenco.com.


THIS ISSUE
SPONSORED BY:

WorksRight Software
Tramenco


BACK ISSUES

TABLE OF CONTENTS

Three Ways to Direct OS/400 Output Queues to TCP/IP Printers

Did OPNQRYF Retrieve Records?

Reader Feedback and Insights: Scheduling a Job to Run More than Once a Day


Editors
Howard Arner
Joe Hertvik
Ted Holt
David Morris

Managing Editor
Mari Barrett

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com



Last Updated: 7/24/02
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.