Indexes

An index is a set of key fields used to identify and access records in a file. To allow for different paths or key fields to a record, a file can have up to 16 indexes.

4GL Index Naming Conventions

In the Database Definition utility (dbdef), indexes are named using the following format:

<FilePrefix>SET<n>, where

  • <FilePrefix> is a three-letter abbreviation for the file.

  • <n> is an integer representing the Index number. The following conventions are often used, although they are not a requirement.

  • 1 is used for the primary (first) Index.

  • 2 through 16 are used for secondary indexes.

    For example, the primary index on the GLMASTER file is GLMSET1.

IBM i Index (Logical) Naming Conventions

The naming convention for indexes (logicals) in the RPG code is as follows:

DB<SystemCode><FilePrefix><IndexNbr>

where <SystemCode> is the system code the file you are inquiring on is associated with, <FilePrefix> is the prefix as defined in the Database Definition utility (dbdef) for the file, and <IndexNbr> is the number of the index you want to use to perform the call.

Most of the calls to the database input/output routines include the logical as part of the call. Whenever you see <Logical> in the documentation for a database input/output routine, it refers to the DB<SystemCode><FilePrefix><IndexNbr> naming convention.