LIMIT

LIMIT(recset, maxrecs [, failclause ] [, KEYED [, COUNT ] ] [, SKIP [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

LIMIT(recset, maxrecs [, ONFAIL(transform) ] [, KEYED [, COUNT ] ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ]

recsetThe set of records to limit. This may be an INDEX or any expression that produces a recordset result.
maxrecsThe maximum number of records allowed on a single supercomputer node.
failclauseOptional. A standard FAIL workflow service call.
KEYEDOptional. Specifies limiting the keyed portion of an INDEX read.
COUNTOptional. Specifies the KEYED limit is pre-checked using keyspan.
SKIPOptional. Specifies that when the limit is exceeded it is simply eliminated from any result instead of failing the workunit.
ONFAILOptional. Specifies outputting a single record produced by the transform instead of failing the workunit.
transformThe TRANSFORM function to call to produce the single output record.
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.

The LIMIT function causes the attribute to fail with an exception if the recset contains more records than maxrecs on any single node of the supercomputer (unless the SKIP option is used for an index read or the ONFAIL option is present). If the failclause is present, it specifies the exception number and message. This is typically used to control "runaway" queries in the Rapid Data Delivery Engine supercomputer.

Example:

RecStruct := RECORD
  INTEGER1 Number;
  STRING1  Letter;
END;
SomeFile := DATASET([{1,'A'},{1,'B'},{1,'C'},{1,'D'},{1,'E'},
                     {1,'F'},{1,'G'},{1,'H'},{1,'I'},{1,'J'},
                     {2,'K'},{2,'L'},{2,'M'},{2,'N'},{2,'O'},
                     {2,'P'},{2,'Q'},{2,'R'},{2,'S'},{2,'T'},
                     {2,'U'},{2,'V'},{2,'W'},{2,'X'},{2,'Y'}],
     RecStruct);
//throw an exception
X := LIMIT(SomeFile,10, FAIL(99,'error!'));
//single record output
Y := LIMIT(SomeFile,10,
      ONFAIL(TRANSFORM(RecStruct,
        SELF := ROW({0,''},RecStruct))));
//no exception, just no record
Z := LIMIT(SomeFile,10,SKIP);
// OUTPUT(X); //This one will throw an exception
OUTPUT(Y);
OUTPUT(Z);

See Also: FAIL, TRANSFORM