The Format 1 START statement modifies the current file position for a relative or indexed file. It defines a beginning point
for retrieval of records from a file.
The Format 2 START statement identifies the beginning of a transaction.
General Format
START file-name
[KEY IS { EQUAL TO } key-name ]
[ { = } ]
[ { GREATER THAN } ]
[ { > } ]
[ { NOT LESS THAN } ]
[ { NOT < } ]
[ { GREATER THAN OR EQUAL TO } ]
[ { >= } ]
[ { LESS THAN } ]
[ { < } ]
[ { NOT GREATER THAN } ]
[ { NOT > } ]
[ { <= } ]
[ { LESS THAN OR EQUAL TO } ]
[ WITH SIZE key-size ]
[ INVALID KEY statement-1 ]
[ NOT INVALID KEY statement-2 ]
[ END-START ]
Format 2
START TRANSACTION
Syntax Rules
- file-name is the name of a relative or indexed file with sequential or dynamic access mode.
- For a relative file,
key-name is the name of the RELATIVE KEY for the file. For an indexed file,
key-name must either be the name of one of the file's record keys or the name of a data item that starts at the beginning of one of
the file's record keys and is not longer than that key.
- statement-1 and
statement-2 are imperative statements.
- key-size is a numeric literal or data item that specifies the maximum number of characters of the key to be examined when setting
the new current file position. With this phrase, the program uses only the first
n characters of the key to find a matching record. If
n is zero or greater than the key size, then the entire key is used. If
n is less than zero, the results are undefined.
- START and TRANSACTION are required words.
Format 1 General Rules
- The START statement changes the current file position for a file in sequential or dynamic access mode. This allows a subsequent
READ NEXT or READ PREVIOUS statement to access a different record.
- file-name must be open in INPUT or I-O mode when the START statement executes.
- If the KEY phrase is missing, the implied operation is EQUAL and the implied
key-name is the primary record key for the file (or the RELATIVE KEY for relative files).
- The START statement changes the current file position and updates the FILE STATUS data item for
file-name. It does not modify the record area for
file-name.
- The comparison specified by the KEY phrase occurs between the contents of
key-name and the records in the file. The current file position is set according to the following rules:
- For EQUAL, "=", NOT LESS, NOT "<", GREATER OR EQUAL, ">=", GREATER, and ">", the current file position is set to the record
with the smallest key that satisfies the given condition.
- For LESS, "<", NOT GREATER, NOT ">", LESS OR EQUAL, and "<=", the current file position is set to the record with the largest
key that satisfies the given condition.
- For relative files, the comparison uses the relative record numbers of the records in the file and the current value of the
RELATIVE KEY data item.
- For indexed files, the comparison uses the current value of
key-name and the values of the corresponding data area for the records in the file.
- If no record is found that satisfies the comparison:
- The invalid key condition exists.
- The START statement is unsuccessful.
- The current file position is undefined.
- If the
invalid-key condition exists, then one of the following actions occurs:
- If the INVALID KEY phrase is specified,
statement-1 executes.
- Otherwise, if an appropriate USE AFTER EXCEPTION procedure exists, it is executed.
- Otherwise, a message is printed and the program halts.
- If the NOT INVALID KEY phrase is specified and the START statement is successful,
statement-2 executes.
- If the START statement is not successful, the current file position and the current Key of Reference are undefined.
Note: The ability to START LESS, "<", NOT GREATER, NOT ">", LESS OR EQUAL, or "<=" is dependent on the host file system. Some file
systems cannot process records in reverse order. These KEY phrases are all used to initiate reverse processing. If you execute
one of these START statements on a machine that does not support READ PREVIOUS, you will get a file error
9B. You can test whether or not a machine has the ability to process files in this manner with the ACCEPT FROM SYSTEM-INFO verb.
See
ACCEPT Statement for more information.
Format 2
- The START TRANSACTION statement identifies the beginning of a transaction. The following rules describe how transaction management
operates with Vision and relative files. For other file systems linked with the runtime, each system's native mechanism for
transaction management is invoked. See the Acucorp interface document for the specific file system for more details.
- The first START TRANSACTION in a program attempts to open the log file for appending. If the log file does not exist, it is
created. START TRANSACTION locks the log file, checks its integrity, then writes a START TRANSACTION notation to the log file
and unlocks it.
- After the START TRANSACTION, each Vision or relative file update operation is recorded until the next COMMIT or ROLLBACK.
At that point, the record of changes is either written to the log file (COMMIT) or discarded (ROLLBACK).
- If you compile with the
-Fs option, an implied START TRANSACTION is in effect. Therefore, if you use this option, and then issue a START TRANSACTION,
the compiler will report an error.
For more information on transaction management, see
Transaction Management in the
ACUCOBOL-GT User's Guide.