Named OUTPUT

[attr := ] OUTPUT(recordset [, format ] ,NAMED( name ) [,EXTEND |,OVERWRITE ] [,ALL])

This form writes the recordset to the workunit with the specified name. This must be a valid label (See Definition Name Rules)

The EXTEND option allows multiple OUTPUT actions to the same named result. The OVERWRITE option is an alternative to EXTEND and replaces the existing named result. The ALL option is used to override the implicit CHOOSEN applied to interactive queries in the ECL IDE program. This specifies returning all records.

When writing multiple OUTPUT actions to the same named result, specify either EXTEND or OVERWRITE. Omitting both may result in a code-generation or runtime error.

Example:

OUTPUT(CHOOSEN(people(firstname[1]='A'),10));
  // writes the A People to the workunit
OUTPUT(CHOOSEN(people(firstname[1]='A'),10),ALL);
  // writes all the A People to the workunit
OUTPUT(CHOOSEN(people(firstname[1]='A'),10),NAMED('fred'));
  // writes the A People to the fred named output
  
//a NAMED, EXTEND example:
errMsgRec := RECORD
  UNSIGNED4 code;
  STRING text;
END;
makeErrMsg(UNSIGNED4 _code,STRING _text) := DATASET([{_code, _text}], errMsgRec);
rptErrMsg(UNSIGNED4 _code,STRING _text) := OUTPUT(makeErrMsg(_code,_text),
                                                  NAMED('ErrorResult'),EXTEND);

OUTPUT(DATASET([{100, 'Failed'}],errMsgRec),NAMED('ErrorResult'),EXTEND);
  //Explicit syntax.

//Something else creates the dataset
OUTPUT(makeErrMsg(101, 'Failed again'),NAMED('ErrorResult'),EXTEND);

//replace any existing named result instead of appending.
OUTPUT(makeErrMsg(103, 'Replacement message'),NAMED('ErrorResult'),OVERWRITE);
  
//output and dataset handled elsewhere.
rptErrMsg(102, 'And again');