11.1 Import Indexes from Database

MPL allows you to import the elements for an index directly from a database. In the INDEX section, where you define the index, enter the keyword DATABASE after the assignment symbol (:=) followed by parentheses containing the table name and the column/field name you want to import from.

     INDEX
        depot := DATABASE("Depots","DepotID");

In the above example, MPL will open the database table Depots, locate the column DepotID, and then read in the entries for the index depot. In most cases the imported indexes are the key fields for the table which are underlined in the following examples.

The column name defaults to the name of the index so if it is the same you do not have to specify it. In the example below the column name in the database table is DepotID which is the same as the index DepotID.

      INDEX
          DepotID  := DATABASE("Depots");

MPL supports multiple databases. The default database is specified in the Database Options dialog box in the Options menu. See Chapter 4.9: The Options Menu for more information.

MPL can import from more than one database in the same run. If you need to import an index from table in a database other than the default, you can do so by specifying the database name before the name of the table. In the example below, MPL will read in the factory index from Access, instead of the default database.

      INDEX
          factory := DATABASE(Access,"Factory","FactID");

MPL also allows you to import subset indexes from database tables.

     INDEX
           FactoryDepot[factory,depot] := DATABASE("FactDep");

The above statement will open the database table FactDep and locate the columns for factory and depot and then read in the entries for FactoryDepot.

Notice that MPL automatically uses the same name as default for the columns FactID and DepotID, as in the original tables the indexes were defined from. If an index column does have a different name than in the original table, you can specify it following the table name by first entering the index name followed by an equal sign and the column name.

       INDEX
          FactoryDepot[factory,depot] :=
             DATABASE("FactDep",factory="Factory",depot="Depot");

This means if you are consistent in naming the columns in different tables you do not have to specify them each time you refer to them in MPL.


Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page