Document revision date: 19 July 1999 | |
Previous | Contents | Index |
The string data-type keys include STRING, DSTRING, COLLATED and DCOLLATED keys. |
Note that the example uses most of the suggested defaults. There are three ways to accept defaults:
When the Edit/FDL utility creates an FDL file, it groups the attributes into major sections. The section headings are called primary attributes, and the attributes within a primary section are called secondary attributes. Certain secondary attributes contain a third level of attributes called qualifiers.
The objective of using the Edit/FDL utility is to create an FDL file with optimum values for the various attributes. An FDL file contains a list of the primary and secondary attributes with related qualifiers. If a primary or secondary attribute does not appear in the FDL file, it is assigned its default value.
Example 4-2 shows an FDL file. IDENT, SYSTEM, FILE, RECORD, AREA n, and KEY n are primary attributes; the others are secondary attributes.
Example 4-2 Sample FDL File |
---|
IDENT " 1-MAR-1993 14:07:46 OpenVMS FDL Editor" SYSTEM SOURCE VMS FILE GLOBAL_BUFFER_COUNT 0 NAME DISK$RMS:[RMSTEST]INDEXED.DAT;3 ORGANIZATION indexed OWNER [RMS1,TEST] PROTECTION (system:RWED, owner:RWED, group:RE, world:) RECORD BLOCK_SPAN yes CARRIAGE_CONTROL none FORMAT variable SIZE 2048 AREA 0 ALLOCATION 233 BEST_TRY_CONTIGUOUS yes BUCKET_SIZE 5 EXTENSION 60 AREA 1 ALLOCATION 5 BEST_TRY_CONTIGUOUS yes BUCKET_SIZE 5 EXTENSION 5 AREA 2 ALLOCATION 18 BEST_TRY_CONTIGUOUS yes BUCKET_SIZE 3 EXTENSION 6 KEY 0 CHANGES no DATA_AREA 0 DATA_FILL 100 DATA_KEY_COMPRESSION no DATA_RECORD_COMPRESSION no DUPLICATES no INDEX_AREA 1 INDEX_COMPRESSION no INDEX_FILL 100 LEVEL1_INDEX_AREA 1 NAME "NUM" NULL_KEY no PROLOG 3 SEG0_LENGTH 8 SEG0_POSITION 0 TYPE bin8 KEY 1 CHANGES yes DATA_AREA 2 DATA_FILL 100 DATA_KEY_COMPRESSION yes DUPLICATES yes INDEX_AREA 2 INDEX_COMPRESSION yes INDEX_FILL 100 LEVEL1_INDEX_AREA 2 NAME "NAME" NULL_KEY yes NULL_VALUE 0 SEG0_LENGTH 39 SEG0_POSITION 9 TYPE string |
When you want to create an FDL file, you invoke the Edit/FDL utility with a DCL command in the following form:
EDIT/FDL/CREATE fdl-filespec |
The /CREATE qualifier specifies that you want to create an FDL file with the name entered in the fdl-filespec parameter. When the Edit/FDL utility displays the main menu, select the INVOKE command. In response to the INVOKE command, the Edit/FDL utility prompts you for a script. The only appropriate scripts for creating a file are INDEXED, RELATIVE, and SEQUENTIAL.
As discussed previously, you can enter a script directly by specifying the /SCRIPT qualifier on the DCL command line. For example, enter the following command to create an indexed FDL file:
$ EDIT/FDL/CREATE/SCRIPT=INDEXED MY_FDL_FILE |
When you select the script, the Edit/FDL utility prompts you for information about the data file. Each prompt consists of a short question, a range of acceptable values (for example, 50-100) or the value type (for example, Keyword, YES/NO, and so forth) in parentheses, and the default answer in brackets. One of the questions in the INDEXED script is shown as follows:
Number of Keys to Define (1-255)[1] : |
In this example, the Edit/FDL utility prompts you for the number of keys you want to define for an indexed data file. The Edit/FDL utility accepts any number from 1 to 255. If you do not specify a value, it assumes that you want to define one key only, the primary key. To accept the default value, press the Return key.
If the Edit/FDL utility requires that you enter a value (that is, no default value is specified for the response), it includes a dash within brackets [-].
When you specify the SEQUENTIAL script or the RELATIVE script, the Edit/FDL utility returns you to the main menu level after finishing the dialog. When you specify the INDEXED script, one of the prompts requests your choice of a design graphics display: a Line_Plot graph or a Surface_Plot graph. After finishing the dialog, the Edit/FDL utility displays the selected graph to help you make your final design choice.
The Line_Plot graph plots bucket size against index depth. All things equal, the size of the buckets determines the number of levels in the index, and the number of levels has a direct effect on the run-time performance of an indexed file. Fewer levels generally reduce the average number of keys searched when the index tree is traversed. However, fewer levels imply more records per data bucket and may cause longer data bucket search times. Thus, the Line_Plot graph helps you decide on the best bucket size for your application. Figure 4-1 shows a Line_Plot graph.
Figure 4-1 Line_Plot Graph
As shown in Figure 4-1, a bucket size of 1 block results in an index with five levels. Increasing the bucket size to 2 blocks reduces the number of index levels to four, but an increase to 5 blocks does not reduce the number of index levels at all. A bucket size of 7 blocks, however, reduces the number of index levels to three.
When you choose the bucket size, remember that the graphs do not display the data level. For example, if you want three levels in the file, then you must limit the number of index levels to two.
The Surface_Plot graphics mode lets you choose a range of values to see their effects. The Edit/FDL utility prompts you to enter a lower and upper bound for one of the following values:
The selected range is displayed along the graph's vertical axis.
The variable on the graph's horizontal axis is bucket size. The numbers in the field portion of the graph show the number of levels at each bucket size for each of the other values.
Figure 4-2 is a Surface_Plot graph that shows a range of values for initial fill factors ranging from 100% to 40%.
Figure 4-2 Surface_Plot Graph
The area on the graph within the slash marks represents combinations that RMS finds acceptable. In Figure 4-2, a fill factor of 70% and a bucket size of 10 blocks is the optimum combination. A fill factor of 70% and a bucket size of 15 blocks is a relatively poor combination because it falls outside of the slash boundaries.
If you are sure the information you supplied to the Edit/FDL utility is valid, the best values are those that lie along the left-hand boundary next to the slash marks. If you are not sure that your information is valid, you should choose a value that lies more to the right of the slash boundary.
When you complete the dialog and the Edit/FDL utility presents the graph, you can make changes to certain attributes of the proposed data file. The design is not complete until you specify "FD" for "Finish Design," at which point the Edit/FDL utility asks a few more questions. You then have the opportunity to return to the main menu to view the file attributes that the Edit/FDL utility has created.
Figure 4-3 shows the attributes that you can alter when the Edit/FDL utility displays the graph. Note that each attribute has a 2-letter mnemonic. To alter an attribute, you specify the corresponding mnemonic. To refresh the display, press the Return key. To begin the final design phase, enter "FD."
Figure 4-3 Design Mnemonics
During the final design phase, the Edit/FDL utility gives you an opportunity to supply values for such attributes as TITLE, an optional primary that allows you to label the FDL file. (Most of these questions are also applicable to designing sequential and relative files.) When you have answered the questions, the Edit/FDL utility assigns the values to the FDL attributes and returns you to the main menu level to display the resulting FDL file.
At the main menu, you can select the ADD command to assign values to any attribute the script omitted. Remember that if an attribute does not appear in the FDL file, it assumes the default value. (For a list of the default values for each attribute, see the OpenVMS Record Management Utilities Reference Manual.) To modify an attribute, use the MODIFY command, and to delete an attribute, use the DELETE command.
To create the displayed FDL file, select the EXIT command. To abort the
session without creating an FDL file, select the QUIT command.
4.1.3 Using the FDL Routines
You can also define file-creation characteristics with the FDL utility routines. The FDL routines provide you with the functions of the File Definition Language, and they allow you to set file creation characteristics from within your application.
FDL$CREATE | Creates a file from an FDL specification, and then closes the file. See Section 4.2.4 for more information. |
FDL$GENERATE | Produces an FDL specification by interpreting a set of control blocks. It then writes the FDL specification either to an FDL file or to a character string. |
FDL$PARSE | Parses an FDL specification, allocates control blocks, and then fills in the relevant fields. |
FDL$RELEASE | Deallocates the virtual memory used by the control blocks created by FDL$PARSE. You must use FDL$PARSE to fill in (to populate) the control blocks if you plan to release the memory with FDL$RELEASE later. |
Because the FDL$GENERATE, FDL$PARSE, and FDL$RELEASE routines allow you to use the run-time, as well as the creation-time, features of RMS, you must call them from a language that can access the control block fields that specify the CONNECT options. This may be difficult from a high-level language.
Example 4-3 shows how to call the FDL$PARSE and FDL$GENERATE routines from a Pascal program.
Example 4-3 Using FDL Routines in a Pascal Program |
---|
[INHERIT ('SYS$LIBRARY:STARLET')] PROGRAM example2 (input,output,order_master); (* This program fills in its own FAB, RAB, and *) (* XABs by calling FDL$PARSE and then generates *) (* an FDL specification by calling FDL$GENERATE.*) (* It requires an existing input FDL file *) (* (TESTING.FDL) for FDL$PARSE to parse. *) TYPE (*+ *) (* FDL CALL INTERFACE CONTROL FLAGS *) (*- *) $BIT1 = [BIT(1),UNSAFE] BOOLEAN; FDL2$TYPE = RECORD CASE INTEGER OF 1: (FDL$_FDLDEF_BITS : [BYTE(1)] RECORD END; ); 2: (FDL$V_SIGNAL : [POS(0)] $BIT1; (* Signal errors; don't return *) FDL$V_FDL_STRING : [POS(1)] $BIT1; (* Main FDL spec is a char string *) FDL$V_DEFAULT_STRING : [POS(2)] $BIT1; (* Default FDL spec is a char string *) FDL$V_FULL_OUTPUT : [POS(3)] $BIT1; (* Produce a complete FDL spec *) ) END; mail_order = RECORD order_num : [KEY(0)] INTEGER; name : PACKED ARRAY[1..20] OF CHAR; address : PACKED ARRAY[1..20] OF CHAR; city : PACKED ARRAY[1..19] OF CHAR; state : PACKED ARRAY[1..2] OF CHAR; zip_code : [KEY(1)] PACKED ARRAY[1..5] OF CHAR; item_num : [KEY(2)] INTEGER; shipping : REAL; END; order_file = [UNSAFE] FILE OF mail_order; ptr_to_FAB = ^FAB$TYPE; ptr_to_RAB = ^RAB$TYPE; byte = 0..255; VAR order_master : order_file; flags : FDL2$TYPE; order_rec : mail_order; temp_FAB : ptr_to_FAB; temp_RAB : ptr_to_RAB; status : integer; FUNCTION LIB$SIGNAL (%REF cond_val: INTEGER; %IMMED num: INTEGER := %immed 0; %STDESCR s1: PACKED ARRAY[L1..U1: INTEGER] OF CHAR := %IMMED 0; %STDESCR s2: PACKED ARRAY[L2..U2: INTEGER] OF CHAR := %IMMED 0): INTEGER; EXTERN; FUNCTION FDL$PARSE (%STDESCR FDL_FILE : PACKED ARRAY [L1..U1:INTEGER] OF CHAR; VAR FAB_PTR : PTR_TO_FAB; VAR RAB_PTR : PTR_TO_RAB) : INTEGER; EXTERN; FUNCTION FDL$GENERATE (%REF FLAGS : FDL2$TYPE; FAB_PTR : PTR_TO_FAB; RAB_PTR : PTR_TO_RAB; %STDESCR FDL_FILE_DST : PACKED ARRAY [L1..U1:INTEGER] OF CHAR) : INTEGER; EXTERN; BEGIN status := FDL$PARSE ('TESTING',TEMP_FAB,TEMP_RAB); if not odd (status) then LIB$SIGNAL(status); flags::byte := 0; status := FDL$GENERATE (flags, temp_FAB, temp_RAB, 'SYS$OUTPUT:'); if not odd (status) then LIB$SIGNAL(status); END. |
For more information about FDL routines, see the OpenVMS Utility Routines Manual.
4.2 Creating a File
After you select the creation characteristics for your file, you use the selected characteristics to create the file. You can create the file using one of the following:
The Create service creates a new data file assigning it the attributes you specify in the FAB and any applicable XABs. Note that where there is a conflict, the XAB fields override the FAB fields.
When you use the Create service to create a file, the file remains open until you explicitly close it.
If you set the create-if (CIF) bit in the FOP (file-processing options) field of the FAB, you can open an existing file with the Create service. If the file you try to create has the same name as an existing file, the Create service opens the existing file instead of creating the new file.
The Create service allows you to set file-creation characteristics and to create the file directly from your application program.
For more information about the Create service, see the OpenVMS Record Management Services Reference Manual.
4.2.2 Using the Create/FDL Utility
Unlike the Create service, using FDL to create a file is a two-step process. You must first create the FDL file using the Edit/FDL utility and then use another RMS utility or your application program to create the data file.
One of the utilities you can use to create a file is the Create/FDL utility (CREATE/FDL). CREATE/FDL creates an empty data file from the specifications in an existing FDL file. This feature allows you to use the Edit/FDL utility to create standard FDL files that describe commonly needed data files and then to use CREATE/FDL to create the data files as they are needed.
For example, to create an empty data file called CUSTRECS.DAT from the specifications in an FDL file called INDEXED.FDL, enter the following DCL command:
$ CREATE/FDL=INDEXED.FDL CUSTRECS.DAT |
Another RMS utility that creates an output data file from the specifications in an FDL file is the Convert utility (CONVERT). However, instead of being empty, the new output file generally contains data records from the input file unless the input file was also empty. Note that the Convert utility processes relative files by sequentially reading records from the input file, then writing them to the output file. As a result the relative record numbers (RRN) change when the input file contains deleted or unused records.
If you want to use CONVERT to change the characteristics of a particular file, you can use a DCL command of the following form:
CONVERT/FDL=fdl-file input-file output-file |
The CONVERT/FDL command creates a new file named by the output-file parameter and assigns the new file the characteristics specified in the FDL file.
For more information about populating data files with CONVERT, see
Section 4.5.
4.2.4 Using the FDL$CREATE Routine
You can also create data files according to your specifications with the FDL$CREATE routine. FDL$CREATE is the FDL routine most likely to be called from a high-level language. It creates a file from an FDL specification and then closes the file.
The FDL$CREATE routine performs the same function as the Create/FDL utility, but it allows you to create data files from your application. However, it allows you to use only the creation-time features of RMS.
Example 4-4 shows how to call the FDL$CREATE routine from a Fortran program.
Example 4-4 Using the FDL$CREATE Routine in a Fortran Program |
---|
* This program calls the FDL$CREATE routine. It * creates an indexed output file named NEW_MASTER.DAT * from the specifications in the FDL file named * INDEXED.FDL. You can also supply a default file name * and a result name (which receives the name of the created * file). The program also returns all statistics. * IMPLICIT INTEGER*4 (A - Z) EXTERNAL LIB$GET_LUN, FDL$CREATE CHARACTER IN_FILE*11 /'INDEXED.FDL'/, 1 OUT_FILE*14 /'NEW_MASTER.DAT'/, 1 DEF_FILE*11 /'DEFAULT.FDL'/, 1 RES_FILE*50 INTEGER*2 FIDBLK(3) /0,0,0/ I = 1 STATUS = FDL$CREATE (IN_FILE,OUT_FILE, DEF_FILE,RES_FILE,FIDBLK,,) IF (.NOT. STATUS) CALL LIB$STOP (%VAL(STATUS)) * STATUS=LIB$GET_LUN(LOG_UNIT) OPEN (UNIT=LOG_UNIT,FILE=RES_FILE,STATUS='OLD') CLOSE (UNIT=LOG_UNIT, STATUS='KEEP') * WRITE (6,1000) (RES_FILE) WRITE (6,2000) (FIDBLK (I), I=1,3) * 1000 FORMAT (1X,'The result filename is: ',A50) * 2000 FORMAT (/1X,'FID-NUM: ',I5/, 1 1X,'FID-SEQ: ',I5/, 1 1X,'FID-RVN: ',I5) * END |
Example 4-5 shows how to call the FDL$CREATE routine from a COBOL program.
Example 4-5 Using the FDL$CREATE Routine from a COBOL Program |
---|
* FDLCR.COB * * This program calls the FDL$CREATE routine. It creates * an indexed output file named NEW_MASTER.DAT from the * specifications in the FDL file named INDEXED.DAT. You * can also supply a default file name and a result name * (that receives the name of the created file). The * program also returns the FDL$CREATE statistics. * * DATA NAMES: * * OUT-REC defines the output record * STATVALUE receives the status value from the routine * call * NORMAL receives the value from SS$_NORMAL * FIDBLOCK receives the FDL$CREATE statistics. There * are three: * (1) file identification number (FID-NUM) * (2) file sequence number (FID-SEQ) * (3) relative volume number (RVN) * RESNAME receives the name of the file that is created * (the result file name) * IDENTIFICATION DIVISION. PROGRAM-ID. FDL-CREATE-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. VAX OBJECT-COMPUTER. VAX INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT OUT-FILE ASSIGN TO 'NEWMASTER.DAT'. DATA DIVISION. FILE SECTION. FD OUT-FILE DATA RECORD IS OUT-REC. 01 OUT-REC. 02 OUT-NUM PIC X(4). 02 OUT-NAME PIC X(20). 02 OUT-COLOR PIC X(4). 02 OUT-WEIGHT PIC X(4). 02 SUPL-NAME PIC X(20). 02 FILLER PIC X(28). WORKING-STORAGE SECTION. 01 MORE-DATA-FLAGS PIC XXX VALUE 'YES'. 88 THERE-IS-DATA VALUE 'YES'. 88 THERE-IS-NO-DATA VALUE 'NO '. 01 STATVALUE PIC S9(9) COMP. 01 FIDBLOCK USAGE IS COMP. 02 NUM PIC S9(9) VALUE 0. 02 SEQ PIC S9(9) VALUE 0. 02 RVN PIC S9(9) VALUE 0. 01 RESNAME PIC X(50). PROCEDURE DIVISION. MAIN. PERFORM CREATE-FILE THRU DISPLAY-STATS. STOP RUN. CREATE-FILE. CALL 'FDL$CREATE' USING BY DESCRIPTOR 'INDEXED.FDL' BY DESCRIPTOR 'NEWMASTER.DAT' BY DESCRIPTOR 'DEFAULT.DAT' BY DESCRIPTOR RESNAME BY REFERENCE FIDBLOCK BY VALUE 0 BY VALUE 0 BY VALUE 0 BY VALUE 0 BY VALUE 0 GIVING STATVALUE. IF STATVALUE IS FAILURE CALL 'LIB$STOP' USING BY VALUE STATVALUE. DISPLAY-STATS. DISPLAY 'The result filename is: ',RESNAME CONVERSION. DISPLAY 'FID number: ',NUM CONVERSION. DISPLAY 'FID sequence: ',SEQ CONVERSION. DISPLAY 'Volume number: ',RVN CONVERSION. |
Previous | Next | Contents | Index |
privacy and legal statement | ||
4506PRO_011.HTML |