The ON NOMATCH command defines the action to take if the prior MATCH command fails (if it is unable to retrieve the specified segment instance). There can be intervening commands between the MATCH and ON NOMATCH commands, and they can be in separate functions.
It is recommended that you query the FocFetch system variable in place of issuing the ON NOMATCH command. FocFetch accomplishes the same thing more efficiently. For more information, see FocFetch.
The syntax of the ON NOMATCH command is
ON NOMATCH command
Is the action that is taken when the prior MATCH command fails.
You can specify any Maintain command except for CASE, DECLARE, DESCRIBE, END, MAINTAIN, MODULE, and another ON command.
The first example displays a message stating that the MATCH was unsuccessful:
MATCH Emp_ID; ON NOMATCH TYPE "Employee was not found in the data source";
This example shows an INCLUDE of a row from the Emp stack:
MATCH Emp_ID FROM Emp(Cnt); ON NOMATCH INCLUDE Emp_ID FROM Emp(Cnt);
The following example shows several commands that are executed after a MATCH command fails:
MATCH Emp_ID; ON NOMATCH BEGIN TYPE "Employee was not found in the data source"; INCLUDE Emp_ID; PERFORM Cleanup; ENDBEGIN