Home | Table of Contents | Return Values of Transformations | CloverETL 4.6.1
--- | --- | ---
Prev | Defining Transformations | Next

### Return Values of Transformations

In those components in which a transformations are defined, some return values can also be defined. They are integer numbers greater than, equal to or less than 0.

| Note
Remember that DBExecute can also return integer values less than 0 in form of SQLExceptions.

- Positive or zero return values

  - ALL = Integer.MAX_VALUE

    In this case, the record is sent out through all output ports. Remember that this variable does not need to be declared before it is used. In CTL, `ALL` equals to `2147483647`, in other words, it is `Integer.MAX_VALUE`. Both `ALL` and `2147483647` can be used.

  - OK = 0

    In this case, the record is sent out through single output port or output port 0 (if component may have multiple output ports, e.g. Reformat, Rollup, etc. Remember that this variable does not need to be declared before it is used.

  - Any other integer number greater than or equal to 0

    In this case, the record is sent out through the output port whose number equals to this return value. These values can be called Mapping codes.

- Negative return values

  - SKIP = - 1

    This value serves to define that error has occurred but the incorrect record would be skipped and process would continue. Remember that this variable does not need to be declared before it is used. Both `SKIP` and `-1` can be used.

    This return value has the same meaning as setting of `CONTINUE` in the Error actions attribute (which is deprecated release 3.0 of CloverETL).

  - STOP = - 2

    This value serves to define that error has occurred but the processing should be stopped. Remember that this variable does not need to be declared before it is used. Both `STOP` and `-2` can be used.

    This return value has the same meaning as setting of `STOP` in the Error actions attribute (which is deprecated since release 3.0 of CloverETL).

    | Important
    The same return value is `ERROR` in CTL1. `STOP` can be used in CTL2.

  - Any integer number less than or equal to -1

    These values should be defined by user as described below. Their meaning is fatal error. These values can be called Error codes. They can be used for defining Error actions in some components (This attribute along with Error log is deprecated since release 3.0 of CloverETL).

| Important
Values greater than or equal to 0 Remember that all return value that are greater than or equal to 0 allow to send the same data record to the specified output ports only in case of DataGenerator, Partition, Reformat, and Rollup. Do not forget to define the mapping for each such connected output port in DataGenerator, Reformat, and Rollup. In Partition (and clusterpartition), mapping is performed automatically. In the other components, this has no meaning. They have either unique output port or their output ports are strictly defined for explicit outputs. On the other hand, CloverDataReader and DBFDataReader always send each data record to all of the connected output ports. Values less than -1 Remember that you do not call corresponding optional `OnError()` function of CTL template using these return values. To call any optional `<required function>OnError()`, you may use, for example, the following function: `raiseError(string Arg)` It throws an exception which is able to call such `<required function>OnError()`, e.g. `transformOnError()`, etc. Any other exception thrown by any `<required function>()` function calls corresponding `<required function>OnError()`, if this is defined. Values less than or equal to -2 Remember that if any of the functions that return `integer` values, returns any value less than or equal to -2 (including `STOP`), the `getMessage()` function is called (if it is defined). Thus, to allow calling this function, you must add `return` statement(s) with values less than or equal to -2 to the functions that return `integer`. For example, if any of the functions like `transform()`, `append()`, or `count()`, etc. returns -2, `getMessage()` is called and the message is written to Console.

| Important
You should also remember that if graph fails with an exception or with returning any negative value less then -1, no record will be written to the output file. If you want that previously processed records are written to the output, you need to return SKIP (-1). This way, such records will be skipped, graph will not fail and at least some records will be written to the output.

Prev | Up | Next
Internal or External Definition | Home | Table of Contents | Error Actions and Error Log (deprecated since 3.0)