Open a database file member

You can open a database file member with statements in your high-level language program. You can also use the control language (CL) open commands: Open Database File (OPNDBF) and Open Query File (OPNQRYF).

To use a database file in a program, your program must issue an open operation to the database file. If you do not specify an open operation in some programming languages, they automatically open the file for you. If you did not specify a member name in your program or on an Override with Database File (OVRDBF) command, the first member (as defined by creation date and time) in the file is used.

If you specify a member name, files that have the correct file name but do not contain the member name are ignored. If you have multiple database files named FILEA in different libraries, the member that is opened is the first one in the library list that matches the request. For example, LIB1, LIB2, and LIB3 are in your library list and all three contain a file named FILEA. Only FILEA in LIB3 has a member named MBRA that is to be opened. Member MRBA in FILEA in LIB3 is opened; the other FILEAs are ignored.

After finding the member, the system connects your program to the database file. This allows your program to perform input/output operations to the file. For more information about opening files in your high-level language program, see the appropriate high-level language topic collection.

You can also open a database file member with the OPNDBF command and the OPNQRYF command. The OPNDBF command is useful in an initial program in a job for opening shared files. The OPNQRYF command is very effective in selecting and arranging records outside your program. Then, your program can use the information supplied by the OPNQRYF command to process only the data it needs.

Related concepts
Control language (CL)
Related reference
Open Database File (OPNDF) command
Open Query File (OPNQRYF) command