In order for your application program to use the open data path
built by the Open Query File (OPNQRYF) command, your program must share the
query file. If your program does not open the query file as shared, then it
actually does a full open of the file it was originally compiled to use (not
the query open data path built by the OPNQRYF command).
Your program will share the query open data path, depending on the following
conditions:
- Your application program must open the file as shared. Your program meets
this condition when the first or only member queried (as specified on the
FILE parameter) has an attribute of SHARE(*YES). If the first
or only member has an attribute of SHARE(*NO), then you must specify SHARE(*YES)
in an Override with Database File (OVRDBF) command before calling your program.
- The file opened by your application program must have the same name as
the file opened by the OPNQRYF command. Your program meets this condition
when the file specified in your program has the same file and member name
as the first or only member queried (as specified on the FILE parameter).
If the first or only member has a different name, then you must specify an
Override with Database File (OVRDBF) command of the name of the file your
program was compiled against to the name of the first or only member queried.
- Your program must be running in the same activation group to which the
query open data path (ODP) is scoped. If the query ODP is scoped to the job,
your program can run in any activation group within the job.
The OPNQRYF command never shares an existing open data path in the job
or activation group. A request to open a query file fails with an error message
if the open data path has the same library, file, and member name that is
in the open request, and if either of the following is true:
- OPNSCOPE(*ACTGRPDFN) or OPNSCOPE(*ACTGRP) is specified for the OPNQRYF
command, and the open data path is scoped to the same activation group or
job from which the OPNQRYF command is run.
- OPNSCOPE(*JOB) is specified for the OPNQRYF command, and the open data
path is scoped to the same job from which the OPNQRYF command is run.
Subsequent shared opens adhere to the same open options (such as SEQONLY)
that were in effect when the OPNQRYF command was run.