Invoke a function

Suppose result is a variable of type INTEGER. The following example shows how to register and invoke a C user-defined function called nFact() that returns N-factorial (n!):
CREATE FUNCTION nFact(arg1 n)
   RETURNING INTEGER;
   SPECIFIC nFactorial
   WITH (HANDLESNULLS, NOT VARIANT)
   EXTERNAL NAME    '/usr/lib/udtype2.so(nFactorial)'
   LANGUAGE C;
EXECUTE FUNCTION nFact (arg1);