A UDF, defined as FENCED, runs in the same job as the SQL statement
that called it. However, the UDF runs in a system thread, separate from the
thread that is running the SQL statement.
Because the UDF runs in the same job as the SQL statement, it
shares much of the same environment as the SQL statement. However, because
it runs under a separate thread, the following threads considerations apply:
- The UDF will conflict with thread level resources held by the SQL statement's
thread. Primarily, these are the table resources discussed above.
- UDFs do not inherit any program adopted authority that may have been active
at the time the SQL statement was called. UDF authority comes from either
the authority associated with the UDF program itself or the authority of the
user running the SQL statement.
- The UDF cannot perform any operation that is blocked from being run in
a secondary thread.
- The UDF program must be created such that it either runs under a named
activation group or in the activation group of its caller (ACTGRP parameter).
Programs that specify ACTGRP(*NEW) will not be allowed to run as UDFs.