Create a sourced function

A sourced function is built over any built-in or existing user-defined function. It can then be altered to suit the needs of the new function. The new function can be used with the system data types or you can add your own data types. For a listing of built-in functions, see Built-in functions. To create a sourced function based on a system function:

  1. In the System i Navigator window, expand the system you want to use.
  2. Expand Databases.
  3. Expand the database and schema that you want to work with.
  4. Right-click the Functions container and select New, then External.
  5. On the New Sourced Function dialog, specify the name by which you want the function to be known in the Function field. The name must not be the same as a procedure that exists in the same schema. Also, the signature of the function must not be the same as any other function that exists in the same schema.
  6. Specify the name of the function on which this function is based in the Source function field.
  7. Select the data type that the function returns. Depending on what type you select, you must also specify the length of the return value in the Length field and the number of digits to the right of the decimal in the Scale field or the CCSID type in the CCSID field. If you selected a large object type, select Return value as a locator to save system resources by deferring or avoiding moving data.
  8. If you want to see the parameters that the function uses, click the Parameters tab.
  9. Click OK.

Notes: