<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en-us" xml:lang="en-us"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="security" content="public" /> <meta name="Robots" content="index,follow" /> <meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' /> <meta name="DC.Type" content="reference" /> <meta name="DC.Title" content="Example 6: Select records using the Open Query File (OPNQRYF) command" /> <meta name="abstract" content="This example shows how to use the Open Query File (OPNQRYF) command many times in a program." /> <meta name="description" content="This example shows how to use the Open Query File (OPNQRYF) command many times in a program." /> <meta name="DC.Relation" scheme="URI" content="rbafodynsrsex.htm" /> <meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" /> <meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" /> <meta name="DC.Format" content="XHTML" /> <meta name="DC.Identifier" content="rbafodynsrex6" /> <meta name="DC.Language" content="en-us" /> <!-- All rights reserved. Licensed Materials Property of IBM --> <!-- US Government Users Restricted Rights --> <!-- Use, duplication or disclosure restricted by --> <!-- GSA ADP Schedule Contract with IBM Corp. --> <link rel="stylesheet" type="text/css" href="./ibmdita.css" /> <link rel="stylesheet" type="text/css" href="./ic.css" /> <title>Example 6: Select records using the Open Query File (OPNQRYF) command</title> </head> <body id="rbafodynsrex6"><a name="rbafodynsrex6"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">Example 6: Select records using the Open Query File (OPNQRYF) command</h1> <div><p>This example shows how to use the Open Query File (OPNQRYF) command many times in a program.</p> <div class="section"><p>You can use the OPNQRYF command more than once in a high-level language program. For example, assume you want to prompt the user for some selection values, then display one or more pages of records. At the end of the first request for records, the user might want to specify other selection values and display those records. This can be done by follow these steps: </p> </div> <div class="section"> <ol><li>Before calling the high-level language program, use an Override with Database File (OVRDBF) command to specify SHARE(*YES).</li> <li>In the high-level language program, prompt the user for the selection values.</li> <li>Pass the selection values to a control language (CL) program that issues the OPNQRYF command (or run the command with a call to program QCMDEXC). The file must be closed before your program processes the OPNQRYF command. You normally use the Close File (CLOF) command and monitor for the file not being open.</li> <li>Return to the high-level language program.</li> <li>Open the file in the high-level language program.</li> <li>Process the records.</li> <li>Close the file in the program.</li> <li>Return to step 2.</li> </ol> </div> <div class="section"><div class="p">When the program completes, run the CLOF command or the Reclaim Resources (RCLRSC) command to close the file, then delete the OVRDBF command specified in step 1. <div class="note"><span class="notetitle">Note:</span> An override command in a called CL program does not affect the open in the main program. All overrides are implicitly deleted when the program is ended. (However, you can use a call to program QCMDEXC from your high-level language program to specify an override, if needed.)</div> </div> </div> </div> <div> <div class="familylinks"> <div class="parentlink"><strong>Parent topic:</strong> <a href="rbafodynsrsex.htm" title="These topics provide examples of selecting records using the Open Query File (OPNQRYF) command.">Select records using the Open Query File (OPNQRYF) command</a></div> </div> </div> </body> </html>