This mandatory clause specifies the data type of the parameter value returned by the function. You can specify any valid data type, including UDTs (note that UDTs are not supported as return data types for Java procedure). It is the responsibility of the user‑written function code to return this value in the proper form.
The defined return data type is stored as an entry in DBC.TVFields using the name RETURN0[n], where n is a sequentially defined integer used to guarantee the uniqueness of the value. This ensures that user‑defined parameter names are not duplicated.
Note that you cannot specify VARIANT_TYPE as the data type for a returned results set, but you can specify TD_ANYTYPE for a returned results set using the following syntax.
… RETURNS TD_ANYTYPE …
If the data type of the returned parameter value would be difficult for the function to create, you can specify the optional CAST FROM option for this clause. This option explicitly casts the returned value into the specified data type. The type casting helps with more complex conversions to ensure they need not be embedded within the function.
The following code fragment illustrates the use of the CAST FROM clause:
… RETURNS DECIMAL(9,5) CAST FROM FLOAT …