APPLY

[attrname := ] APPLY(dataset, actionlist [ , BEFORE( actionlist ) ] [ , AFTER( actionlist [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ]) ] )

attrnameOptional. The action name, which turns the action into an attribute definition, therefore not executed until the attrname is used as an action.
datasetThe set of records to apply the action to. This must be the name of a physical dataset of a type that supports this operation.
actionlistA comma-delimited list of the operations to perform on the dataset. Typically, this is an external service (see SERVICE Structure). This may not be an OUTPUT or any function that triggers a child query.
BEFORESpecifies executing the enclosed actionlist before the first dataset row is processed. Not yet implemented in Thor, valid only in hthor and Roxie.
AFTERSpecifies executing the enclosed actionlist after the last dataset row is processed. Not yet implemented in Thor, valid only in hthor and Roxie.
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 APPLY action performs all the specified actions in the actionlist on each record of the nominated dataset. The actions execute in the order they appear in the actionlist.

Example:

EXPORT x :=  SERVICE
  echo(const string src):library='myfuncs',entrypoint='rtlEcho';
END;
APPLY(person,x.echo(last_name + ':' + first_name));
 // concatenate each person's lastname and firstname and echo it

See Also: SERVICE Structure, DATASET