JKEYED Verb — Create Journaled File
Syntax
JKEYED fileid,keysize,records,recsize{,ERR=lineref}
JKEYED fileid,keydef{,keydef...},records,recsize{,ERR=lineref}
Description
The JKEYED verb creates a keyed file that is similar to an MKEYED file,
but supports journaling and transactions. See Journaled
Files and Transactions for more information.
The first syntax example shows how to define a JKEYED file with only one
key per record.
The second syntax example shows how to define a JKEYED file with more than
one key per record. In this case, each key must be present within the
data record. The bracketed expressions indicate the locations of keys
within the record. Bracketed expressions separated by plus (+) signs indicate
a composite key made up from several parts of the record. See MKEYED
Verb - Create MKEYED File for additional information.
Note that the records parameter
is included only for consistency with the MKEYED verb, and should be specified
as 0 for all JKEYED file definitions.
Parameter |
Description |
fileid |
Name of the new file, which is a simple filename created in the directory in which the journaled filesystem was initialized. |
keysize |
Maximum length of a key in the file, which must be an integer. |
keydef |
Key definition. Each keydef has the following syntax: segment{+ segment...} Each segment has the following syntax: [{ field:} offset:len{ :flags}] |
records |
Maximum number of records is ignored, and should be specified as 0. |
recsize |
Maximum record size in bytes. JKEYED files work with true variable-length records. This value must be an integer in the range 0 to (2^31)-1. Unlike all other record-oriented BBx and BBj file types, JKEYED records are not padded to the maximum defined length with $00$ characters. A READ RECORD on a JKEYED channel will return exactly the number of characters that were originally written to the file. A JKEYED file with a maximum record size of zero has no data, only keys. Note: The system allocates internal memory buffers based on this maximum record size. Specifying an unnecessarily large maximum record size will increase the memory requirements and can decrease overall performance. The maximum record size should typically be defined based on the largest expected record size, with some allowance for growth. |
ERR=lineref |
Branch to be taken if an error occurs during execution. |
Sort Operation Flags
The following flags are available to control sorting operations. A flag may be used on any segment of a composite key.
Flag |
Description |
"D" |
Sorts the key segment in descending order, and only the segment flagged is affected. To sort the entire key in descending order, each segment must be flagged. |
"U" |
Issues an !ERROR=11 when a duplicate key is detected on a WRITE. Determine the key chain and key that is duplicated. If this flag is not used, alternate keys can be duplicated, but the order is unspecified. Unlike the "D" flag, the "U" flag affects the entire key chain. |
"B" |
Sorts a key segment numerically, provided the segment is exactly 8 bytes long and contains a business floating point quantity (string template data type "B"). |
The primary key will accept the "D" flag, but the "U" flag is there by default and cannot be reset.
JKEYED "MYFILE",[1:1:2],[2:1:10:"D"],0,80
Note: When using flags on composite key segments, especially segments other than the first segment, set up a test file to verify that the order you desire is in fact the order you are getting.
Examples
Example 1
The following defines a simple JKEYED file with one key per record similar to a DIRECT file:
JKEYED "MYFILE",10,0,1000
Example 2
The following defines a JKEYED file with two keys of one segment each. The brackets indicate where in the record the key can be found.
JKEYED "MYFILE",[1:4:2],[2:1:10],0,1000
Example 3
The following defines a JKEYED file with three keys, one of which is composed of two segments. The "+" used between bracket expressions indicates a composite key.
JKEYED "MYFILE",[1:1:10]+[2:1:5],[1:25:2:"D"],[4:12:20],0,1000