Preparing the Database

GT.M databases consist of one or more RMS files. Most database files have a RMS file structure externally and a GT.M Database Structure (GDS) internally. Management of the GDS files by the GT.M run-time system assures high performance and integrity. GT.M database files are coordinated by a Global Directory. The Global Directory identifies which global names belong in which files, and specifies the creation characteristics for each file. To specify access to a database, each M process must define the GTM$GBLDIR logical name to point to the associated Global Directory.

To define and maintain a Global Directory, use the Global Directory Editor (GDE) utility. The MUPIP command CREATE uses the characteristics as defined in the Global Directory to create the associated database. In a production environment, the system manager typically maintains Global Directories.

For more information on GDE and MUPIP refer to the "Global Directory Editor" and "MUPIP" chapters in the GT.M Administration and Operations Guide .

Example:

This example is a sequence of events that illustrate steps you might typically perform in creating a new global directory, in our example PAYROLL.GLD. To assist you in following the sequence, each actual step appears in typewriter font, as you might see on your terminal screen, followed by an explanation in normal text font.

To explain the program development cycle, a sample routine is created and used in each subsequent section to illustrate the functionality being described. A routine named PAYROLL calls parts of the routine TAXES with the M commands "DO STATE^TAXES" and "DO FEDERAL^TAXES." Both the PAYROLL and TAXES routines call the general-purpose routines LOOKUP and SUM.

For the purposes of the example, assume we have already compiled and debugged the LOOKUP and SUM routines.

        $ DIR PAYROLL.* 
        %DIRECT-W-NOFILES, no files found
      

The DIRECTORY command checks to see that there are no existing files with the name PAYROLL.

        $ DEFINE GTM$GBLDIR PAYROLL.GLD 
        $ GDE 
        %GDE-I-GDUSEDEFS, Using defaults for Global Directory
        USER:[EXAMPLE]PAYROLL.GLD
      

The DEFINE command establishes the current value of the logical name GTM$GBLDIR as PAYROLL.GLD. GT.M uses the logical name GTM$GBLDIR to identify the current Global Directory. Because we defined it in the process logical table, GTM$GBLDIR maintains the defined value only for the current login session. The next time we log into VMS, we must again define the value of as GTM$GBLDIR as PAYROLL.GLD to use it as the current Global Directory. If you use a Global Directory frequently, DEFINE the GTM$GBLDIR to that Global Directory in a LOGIN.COM file. The system manager may include such a definition in the system login file, or in a system or group logical name table.

This example defines GTM$GBLDIR without a directory specification. The logical name points to the PAYROLL.GLD file in the current RMS default directory. Therefore if the default directory changes, GT.M attempts to locate the Global Directory in the new default directory and cannot use the original file. If you intend for the Global Directory to consistently point to this file, even if the default directory changes, use a full file-specification for GTM$GBLDIR.

This invokes the Global Directory Editor by entering GDE at the DCL prompt.

GDE>SHOW/ALL

*** TEMPLATES ***

 Def Rec Key Null
Region Coll Size Size Subs Journaling
----------------------------------------------------------
<default> 0 256 64 N N

Segment Active Acc Typ Block Alloc Exten Options
----------------------------------------------------------
<default> * BG DYN 1024 100 100 GLOB=1024
LOCK= 40
<default> * MM DYN 1024 100 100 DEFER
LOCK= 40

*** NAMES ***
Global Region
------------------------------------------------------------
* DEFAULT

*** REGIONS ***

Dynamic Def Rec Key Null
Region Segment Coll Size Size Subs Journaling
-----------------------------------------------------------------
$DEFAULT $DEFAULT 0 256 64 N N

*** SEGMENTS ***
Segment File(ext:.dat) Acc Typ Block Alloc Ext Options
-----------------------------------------------------------------
$DEFAULT MUMPS BG DYN 1024 100 100 GLOB=128
                                   LOCK= 40
                                    RES = 0 


*** MAP ***
- - Names - - File
From Up to Region Segment ext:.dat)
-----------------------------------------------------------------
% ... $DEFAULT $DEFAULT MUMPS
LOCAL LOCKS $DEFAULT $DEFAULT MUMPS
      

The GDE SHOW command displays the default Global Directory.

        GDE>CHANGE /SEGMENT $DEFAULT /ALLOCATION=1000 /FILE=PAYROLL.DAT
      

The GDE CHANGE command sets the database file name to PAYROLL.DAT, and specifies a file size of 1000 blocks (of 1024 bytes).

        GDE>EXIT
      
        %GDE-I-VERIFY, Verification OK
      
        %GDE-I-GDCREATE, Creating Global Directory file
        USER:[EXAMPLE]PAYROLL.GLD
      
        %GDE-I-GDEIS, Global Directory
      

The GDE EXIT command terminates GDE. The Global Directory Editor creates a default Global Directory and displays a confirmation message.

        $ DIR PAYROLL.*
        Directory USER:[EXAMPLE]
        PAYROLL.GLD;1
        Total of 1 file.
      

The final DIRECTORY command shows the new Global Directory.

In the simplest case, running the Global Directory Editor and immediately EXITing creates a Global Directory with a default single file database.

To create the database file PAYROLL.DAT, use the GT.M MUPIP CREATE utility.

Example:

         $ MUPIP CREATE
         Database file for region $DEFAULT created.
      

The MUPIP CREATE command generates the database file. Notice that the MUPIP CREATE syntax does not include the file name. MUPIP uses the logical name GTM$GBLDIR to find the Global Directory PAYROLL.DAT and obtains the file name from that Global Directory. MUPIP then checks to make sure that PAYROLL.DAT does not already exist and creates PAYROLL.DAT with the characteristics described in PAYROLL.DAT.

Example:

          $ MUPIP LOAD PAYROLL.GLO
          GT.M MUPIP EXTRACT
          09-OCT-2001 11:26:44
          %MUPIP-I-KEYCNT, LOAD TOTAL:
          keycnt: 100 max subsc len:12 max data len: 3
          %MUPIP-I-RECCNT, Last record number: 202
      

This uses the MUPIP LOAD command to load a sequential file into the database.

Because MUPIP uses the logical name GTM$GBLDIR to locate a Global Directory (which identifies the database file(s)), the LOAD command does not require any information about the target database. Most of the GT.M utilities work this way, with few exceptions.