You should register the UDF or method to DB2 after you have written and completely tested the actual code. Note that it is possible to define the UDF or method prior to actually writing it. However, to avoid any problems with running your UDF or method, you are encouraged to write and test it extensively before registering it. For information on testing your UDFs and methods, see Debugging your UDF.
Use the CREATE FUNCTION statement to define (or register) your UDF to DB2. To register a method with DB2, use the CREATE TYPE or ALTER TYPE statement to define a method for a structured type, then use the CREATE METHOD statement to associate the method body with the method specification. You can find detailed explanations for these statements and their syntax in the SQL Reference.