Software AG Products 2.4.1 | Reference Guide | Execution Commands | Detailed Syntax | @FIND
 
@FIND
The @FIND command performs queries against the database, according to the search criteria provided in the @ADADCL command suffixed with the same nnnn identifier.
The syntax of the command is as follows:
syntax of find
The result of this command is either a no-hit indication, expressed by the Adabas Pre-Compiler defined EOF variable, or a list of ISNs that satisfy the query accompanied with the first record read into the appropriate record buffer.
If the total number of ISNs satisfying a @FIND command exceeds the capacity of the ISN buffer, the overflow list is stored on the WORK data set, and is automatically obtained by the @READNEXT command. Note that for performance efficiency, the approximate number of ISNs that are expected to be returned. Software AG recommends to provide a somewhat higher figure for the isn-buffer-size parameter of the corresponding @ADADCL command.
The @FIND command has three major types:
Regular @FIND Command
Before issuing the @FIND command, move the desired values to be applied by the logical search criteria of the corresponding @ADADCL command to the value buffer.
For example:
@FIND5.
You may use the HOLD option in this command, however when multiple records are found, only the first one is held. For example:
@FIND5 HOLD SAVE.
The RETURN option indicates that Response Code 145 should be returned if the required record is already held by another user.
@FIND SORTED BY
The ISN list may be sorted on up to three descriptors, expressed by up to three parameters of the SORTED BY clause, where del through de3 are the full descriptor names. The user may specify the DESCENDING keyword for descending sequence, otherwise the ISNs are sorted in ascending order.
For example:
@FIND3 SORTED BY NAME SAVE.
Note that the HOLD option should not be used together with the SORTED clause. The user may use the NOREAD clause followed by an extra @READNEXT command with the HOLD keyword.
@FIND COUPLED
This option is used to retrieve records from the file declared in the corresponding @ADADCL command that are coupled to a given record in another file.
The user specifies the file name of the file and the ISN of the record to which other records are to be coupled. id1 may be the ISN number or an identifier containing the ISN number.
The list of ISNs is placed in the ISN buffer and the first record is read into the record buffer.
The HOLD option must not be used together with the COUPLED clause. In that case, use the NOREAD clause followed by the @READNEXT command with the HOLD keyword.
For this option, the user need not refer to the value buffer and the two files must be physically coupled.
For example:
@ADADCL1, EMPLOYEES . . . . . . . .
@ADADCL2, VEHICLES. . . . .
.
.
@FIND1.
PERFORM EX1 UNTIL EOF1.
.
.
EX1.
@FIND2 COUPLED=EMPLOYEES ISN=ISN1.
PERFORM EX2 UNTIL EOF2.
@READNEXT1.
EX2.
.
.
@READNEXT2.
In this example, files EMPLOYEES and VEHICLES are coupled. For each record found in file EMPLOYEES, we read all the coupled records in file VEHICLES. In EX2 we have the fields from both files with the exception that there may be some records in file VEHICLES that are coupled to the same records in file EMPLOYEES.
Note that the @FIND command is to be issued only once for one desired set of search criteria values. Further handling of the ISN list produced by the @FIND command is to be done by the @READNEXT command.
If processing of the ISN list produced from a @FIND command by using the @READNEXT command is not continued until the EOF indication and the program issues another @FIND, which employs the same USERVIEW but for different values for the search-criteria, use the RELEASE keyword in the new @FIND in order to release the ISN list.
If you are only interested in the quantity of records found and do not intend to access any records, use the NOCID option of the corresponding @ADADCL command. In this case, Adabas does not generate an ISN, therefore there is no need to release the ISN list.
The SAVE option retains the entire ISN list indefinitely. A saved ISN list can be released only by the @RELEASE or @CLOSE commands, or by using the RELEASE keyword in the following @FIND command with the same nnnn identification.
The NOREAD option causes the command to be executed without reading the first record. This record is read during the execution of the first @READNEXT command.
The RELEASE option causes the command to automatically release the previous ISN list generated by the previous execution of the command.
The GETNEXT option causes Adabas Pre-Compiler to generate code to work with the Adabas GETNEXT option. In this case, the ISN buffer is not used and the user may use PREFETCH and SECURITY BY VALUE.
The PASSWORD parameter is for protected files and the user may supply an identifier containing a valid password.
The CIPHER parameter is for ciphered files and the user may supply an identifier containing a valid cipher code.
The MAXTIME option is used to limit the execution time of the command. Specify a number or the identifier containing the number of seconds which is the limit for the command.