START Statement

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

  1. file-name is the name of a relative or indexed file with sequential or dynamic access mode.
  2. 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.
  3. statement-1 and statement-2 are imperative statements.
  4. 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.
  5. START and TRANSACTION are required words.

Format 1 General Rules

  1. 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.
  2. file-name must be open in INPUT or I-O mode when the START statement executes.
  3. 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).
  4. 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.
  5. 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:
    1. 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.
    2. 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.
  6. 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.
  7. 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.
  8. If no record is found that satisfies the comparison:
    1. The invalid key condition exists.
    2. The START statement is unsuccessful.
    3. The current file position is undefined.
  9. If the invalid-key condition exists, then one of the following actions occurs:
    1. If the INVALID KEY phrase is specified, statement-1 executes.
    2. Otherwise, if an appropriate USE AFTER EXCEPTION procedure exists, it is executed.
    3. Otherwise, a message is printed and the program halts.
  10. If the NOT INVALID KEY phrase is specified and the START statement is successful, statement-2 executes.
  11. 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

  1. 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.
  2. 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.
  3. 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).
  4. 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.