ON NOMATCH

How to:

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.


Top of page

x
Syntax: How to Use the ON NOMATCH Command

The syntax of the ON NOMATCH command is

ON NOMATCH command

where:

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.



Example: Using ON NOMATCH

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

WebFOCUS