Skip to main content

IBM DB2 for i: Tips

Function not found

"Function not found" is a common error condition when invoking a User-Defined Function (UDF) for the first time and is often easily corrected.

How the "Function not found" error can occur
DB2 for i checks the signature (ie, the data types) when it attempts to resolve a call to a UDF. This signature is subject to data type promotion rules. If any of the data types for this UDF are incompatible, the user will receive the "Function not found" error.

The most common programming error with UDF data type promotion involves the character parameters (CHAR). This situation is best understood with an example UDF, which we've named countpart.

CREATE FUNCTION countpart(partcode CHAR(10) )
  RETURNS INTEGER
LANGUAGE SQL 
BEGIN
  DECLARE partcnt INTEGER;
  SET partcnt = SELECT count(*) FROM parts WHERE code=PARTCODE;
  RETURN partcnt;
END;

In this example, the countpart UDF is created with an input parameter defined to be a CHAR(10). Each time the application tries to invoke the function as follows,

  SELECT * FROM orders WHERE countpart

We're here to help

Easy ways to get the answers you need.


or call us at
1-866-883-8901
Priority code:
101AR13W

DB2 Web Query

Web based query and reporting


IBM i for BI Solution

IBM i for Business Intelligence is a packaged solution that is easy to order and easy to implement, and easy to maintain. Everything you need for an out of box analytical solution based on IBM i and DB2 Web Query.