Defining native database files for iSeriesC programs

You must consider a number of issues when preparing your EGL programs and data for use with native database files in the iSeriesC target environment.

Applying EGL record organization to IBM i files

EGL programs use the IBM® i file system to implement EGL file I/O statements. The IBM i file system supports physical files and simple logical files. A physical file contains actual data stored on the system. A simple logical file presents a view of the data from a physical file. The following table shows the EGL record stereotypes that support file I/O statements and the corresponding iSeriesC file types. Select the EGL record stereotype that best fits the program being developed. See your IBM i documentation for details on using physical and logical files.

Table 1. EGL record stereotypes and recommended iSeriesC file types
EGL record stereotype iSeries® file type
IndexedRecord Physical file or logical file
RelativeRecord Physical file
SerialRecord Physical file

Creating and naming files

EGL requires that all files accessed by the program exist on the system before using EGL I/O statements on the files. The file I/O statements do not create a file for the program user.

You specify the names of files used by a program as system resource names during generation. The default system resource name for a file is the name you assigned during record definition. You can change the default name to some other name. You can also explicitly qualify a file name by adding a library name, using the form library/filename. If you do not explicitly qualify a file name, EGL searches for the file in the library list (*LIBL) when the program runs in the iSeriesC environment.

Set the genDDSFile build descriptor option to YES if you want EGL to generate the data description specifications (DDS) information for you based on the serial, indexed, or relative record definition.

Note: You can use other methods for creating files, such as the Interactive Data Definition Utility and SQL. However, because DDS is the most commonly used method, it is used here.

To create a physical file, use the create physical file (CRTPF) command. You can create physical files having the EGL relative and serial record stereotypes with or without the DDS source information. Files with the relative and serial record stereotypes are arrival-sequenced files. If you do not use the DDS source information to create these files, you must specify the record length for the file using the RCDLEN parameter on the CRTPF command.

Use the DDS source information provided by EGL to create physical and logical files that have the EGL indexed record stereotype. Use the create physical file CRTPF command to create physical files and the create logical file CRTLF command to create logical files. Files having the indexed record stereotype are key-sequenced files. The DDS source information provides the means for specifying the key fields.

Sharing database files

EGL programs can share the record position or pointer of a file with another program or program in the same job. Use the SHARE(*YES) parameter on the [[[IBM i]]]] CREATE, CHANGE, or OVERRIDE file commands for file sharing. SHARE(*NO) maintains the independence of the record position within the file for each program accessing the file.

Relative record file initialization

Initialize file members that correspond to the EGL relative record stereotype before attempting to use them. Relative record files are represented in the iSeriesC environment by physical files whose records are retrieved and manipulated by a relative record number. When you update or add a record to a relative file member, a place must exist in the member for the record. For an update, that place must be a valid, existing record; for a new record, that place must be a deleted record. Use the Initialize Physical File Member (INZPFM) command to initialize records for relative file members.

Record lock considerations

The EGL get...forUpdate statement reads a record from a file and locks the record as exclusive allow read. This means that no other user can update this record until the user who locked the record releases the record with an I/O statement other than get...forUpdate. If one user attempts to update a record that is already held for update by another user, an EGL deadlock error occurs.

Using data description specifications generated by EGL

If you set the genDDSFile build descriptor option to YES, EGL can generate DDS information from EGL record definitions that are used for file I/O statements.

The DDS information generated by EGL is useful only to an IBM i system administrator or program developer. The system administrator can use the DDS source members, or modified versions of them, to create the files that do not already exist in the iSeriesC environment. Using the DDS source information to create the files qualifies these files for IBM i data management functions, such as specifying key fields, unique keys, and logical files.

You are not required to use the DDS source information to create files because EGL does not require that the files a program accesses be externally described. EGL relies on the record definition, which is built into the *PGM object, for the structure of a record. However, using the DDS information guarantees agreement between the way the program defines the record structure and the record data stored in the iSeriesC environment.

Restrictions on logical files

EGL supports simple logical files that use only one record format. The DDS source information specifies only one file on the PFILE keyword. For more information on using DDS keywords, see the i5/OS™ Information Center.


Feedback