Dictionary L-type records

Dictionary L-Type Records

Top  Previous  Next

 

An L-type record represents a link to another file. It can be used in query processor commands to reference fields in a dependent file without the need to create an I-type TRANS() expression for each field. Links can also be used within I-type expressions to minimise the number of explicit TRANS() operations.

 

1:L  { descriptive text }
2:Id expression
3:File name
4:{File expression}

 

The expression in field 2 is constructed in exactly the same was as an I-type expression and derives the record id of the record(s) in the linked file from data in the original file.

 

Links can be used to reference A, C, D, I or S-type items in the remote file.

 

The optional file expression in field 4 allows for more complex linking where the file to be referenced is one of a number of files that share a common dictionary, for example, sales divided by region. The name in field 3 is used to identify the file whose dictionary should be referenced to look up names used in the expressions in fields 2 and 4. The file expression in field 4 derives the name of the actual file to be referenced when retrieving data. Where field 4 is empty, the file name in field 3 is used for both purposes.

 

 

Examples

 

If a library application has two files, BOOKS and TITLES where the record id of BOOKS is formed from the id of the corresponding TITLES record and the copy number separated by a hyphen, the following link placed in the dictionary of the BOOKS file could be used to access the associated TITLES record:

 

1:  L

2:  @ID['-', 1, 1]

3:  TITLES

 

Queries based on the BOOKS file could then reference data from the TITLES file using field names made up from the name of the link record, a % character and the name of the TITLES field to be accessed. For example, if the above link was named TTL, a query such as

LIST BOOKS TTL%TITLE TTL%AUTHOR

could be used to print a list of book titles and their authors.

 

 

The same data could be referenced in an I-type item in the dictionary of the BOOKS file by use of simply

TTL%TITLE

as the expression (field 2). This is exactly equivalent to writing

TRANS(TITLES, @ID['-' , 1, 1], TITLE, 'X')

Use of links in this way removes the need to include the link expression (@ID['-', 1, 1]) in every reference to items in the TITLES file. Because use of a link causes a compile time substitution of the actual TRANS() operation, changing the link record requires all I-types that use it to be recompiled.

 

 

Multiple Links

 

A link may reference an item that is itself a further link. Extending the above example, there might be a READERS file that has a record for each user of the library and includes a LOANS field that lists the books on loan to the reader. The link from the READERS file to the BOOKS file becomes

OUT

1: L

2: LOANS

3: BOOKS

 

Finding the titles of the books on loan might then require a query command of the form

LIST READERS OUT%TTL%TITLE