KeyOnly: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The READ statement's KEYONLY parameter allows you to read both the key and the record number in a keyed file without reading the corresponding record in the master file. This feature was implemented to return the key if the master file record is locked and is being read by key. It can also be used to obtain keys sequentially, without the overhead of reading the master file.
The [[READ]] statement's '''KEYONLY''' parameter allows you to read both the key and the [[record number]] in a [[keyed file]] without reading the corresponding record in the [[master file]]. This feature was implemented to return the key if the master file record is locked and is being read by key. It can also be used to obtain keys [[sequentially]], without the overhead of reading the master file.


The KEYONLY parameter is valid only for files opened INPUT KEYED or OUTIN KEYED. It may be used with positional parameters to specify the key that is to be read. If no positional parameter is specified, the next key will be read. FORM statements corresponding to the key length and B 4 for the record number should be used. If the record length of the master file is not at least four bytes more than the key length, the record number is not returned.
The KEYONLY parameter is valid only for files opened [[INPUT]] [[KEYED]] or [[OUTIN]] KEYED. It may be used with positional parameters to specify the key that is to be read. If no positional parameter is specified, the next key will be read. [[FORM]] statements corresponding to the [[key length]] and B 4 for the record number should be used. If the record length of the master file is not at least four bytes more than the key length, the record number is not returned.


Read file KEYONLY without having read a master record to allocate a buffer caused the task to hang.  BR has always required a master record to be read before accessing a file KEYONLY.  Now this error condition produces BR error [[0718]].
Read file KEYONLY without having read a master record to allocate a buffer caused the task to hang.  BR has always required a master record to be read before accessing a file KEYONLY.  Now this error condition produces BR error [[0718]].


While Business Rules reads only the key file when the KEYONLY parameter is used, it does move the file pointer in the master file to the position of the record just read.
While Business Rules! reads only the key file when the KEYONLY parameter is used, it does move the file pointer in the master file to the position of the record just read.


Note that it is very important to keep the key file updated if this feature is to be used. Otherwise, READ with the KEYONLY parameter could return an incorrect record in a situation where a master file record is deleted or rewritten after a READ with a REC= parameter.
Note that it is very important to keep the key file updated if this feature is to be used. Otherwise, READ with the KEYONLY parameter could return an incorrect record in a situation where a master file record is deleted or rewritten after a READ with a REC= parameter.


A REREAD, DELETE, or REWRITE following a READ with the KEYONLY parameter will return an error.
A [[REREAD]], [[DELETE]], or [[REWRITE]] following a READ with the KEYONLY parameter will return an error.


[[Category:All Parameters]]
[[Category:All Parameters]]

Revision as of 18:06, 11 January 2016

The READ statement's KEYONLY parameter allows you to read both the key and the record number in a keyed file without reading the corresponding record in the master file. This feature was implemented to return the key if the master file record is locked and is being read by key. It can also be used to obtain keys sequentially, without the overhead of reading the master file.

The KEYONLY parameter is valid only for files opened INPUT KEYED or OUTIN KEYED. It may be used with positional parameters to specify the key that is to be read. If no positional parameter is specified, the next key will be read. FORM statements corresponding to the key length and B 4 for the record number should be used. If the record length of the master file is not at least four bytes more than the key length, the record number is not returned.

Read file KEYONLY without having read a master record to allocate a buffer caused the task to hang. BR has always required a master record to be read before accessing a file KEYONLY. Now this error condition produces BR error 0718.

While Business Rules! reads only the key file when the KEYONLY parameter is used, it does move the file pointer in the master file to the position of the record just read.

Note that it is very important to keep the key file updated if this feature is to be used. Otherwise, READ with the KEYONLY parameter could return an incorrect record in a situation where a master file record is deleted or rewritten after a READ with a REC= parameter.

A REREAD, DELETE, or REWRITE following a READ with the KEYONLY parameter will return an error.