CATCH

result := CATCH( recset, action [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] );

resultThe definition name for the resulting recordset.
recsetThe recordset expression that, if it fails, causes the action to launch.
actionOne of the three valid actions below.
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options.
Return:CATCH returns a set of records (which may be empty).

The CATCH function executes the action if the recset expression fails for any reason.

Valid actions are:

SKIPSpecifies ignoring the error and continuing, returning an empty dataset.
ONFAIL(transform)Specifies returning a single record from the transform function. The TRANSFORM function may use FAILCODE and/or FAILMESSAGE to provide details of the failure and must result in a RECORD structure the same format as the recset.
FAILThe FAIL action, which specifies the error message to produce. This is meant to provide more useful information to the end user about why the job failed.

Example:

MyRec := RECORD
    STRING50 Value1;
    UNSIGNED Value2;
END;

ds := DATASET([{'C',1},{'C',2},{'C',3},
               {'C',4},{'C',5},{'X',1},{'A',1}],MyRec);

MyRec FailTransform := TRANSFORM
  self.value1 := FAILMESSAGE[1..17]; 
  self.value2 := FAILCODE
END;

limited1 := LIMIT(ds, 2);
limited2 := LIMIT(ds, 3);
limited3 := LIMIT(ds, 4);

recovered1 := CATCH(limited1, SKIP);
recovered2 := CATCH(limited2, ONFAIL(FailTransform));
recovered3 := CATCH(CATCH(limited3, FAIL(1, 'Failed, sorry')), ONFAIL(FailTransform));

OUTPUT(recovered1);  //empty recordset 
OUTPUT(recovered2);  //
OUTPUT(recovered3);  //

See Also: TRANSFORM Structure, FAIL, FAILCODE, FAILMESSAGE