SQL User‑Defined Functions and Large Objects
The usage characteristics for an SQL UDF with large object parameters or a large object return value are the same as the usage characteristics for any other UDF. In general, you can specify a UDF that accepts a LOB value as an argument in any context in which a UDF is otherwise allowed. You can also use an SQL UDF that returns a LOB value in any context in which a value of that type is appropriate and a UDF is otherwise allowed.
As with other functions and operators, Teradata Database can apply automatic type conversions to the arguments or the return values of an SQL UDF. You should be careful about the possible performance implications of automatic type conversions with large objects used as UDF parameters.
For example, a function whose formal parameter is a BLOB type could be passed a VARBYTE column as the actual argument. Teradata Database converts the VARBYTE value into a temporary BLOB and then passes that to the SQL UDF. Because even a temporary BLOB is stored on disk, the performance cost of the conversion is significant. To avoid this, you should consider creating an overloaded function that explicitly accepts a VARBYTE argument.
Another possible cause of undesired conversions is truncation. Declared length is part of the data type specification.