result := CATCH( recset, action [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] );
result | The definition name for the resulting recordset. |
recset | The recordset expression that, if it fails, causes the action to launch. |
action | One of the three valid actions below. |
UNORDERED | Optional. Specifies the output record order is not significant. |
ORDERED | Specifies the significance of the output record order. |
bool | When False, specifies the output record order is not significant. When True, specifies the default output record order. |
STABLE | Optional. Specifies the input record order is significant. |
UNSTABLE | Optional. Specifies the input record order is not significant. |
PARALLEL | Optional. Try to evaluate this activity in parallel. |
numthreads | Optional. Try to evaluate this activity using numthreads threads. |
ALGORITHM | Optional. Override the algorithm used for this activity. |
name | The 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:
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, dude')), ONFAIL(FailTransform)); OUTPUT(recovered1); //empty recordset OUTPUT(recovered2); // OUTPUT(recovered3); //
See Also: TRANSFORM Structure, FAIL, FAILCODE, FAILMESSAGE