Use qualified function reference

If you use a qualified function reference, you restrict the search for a matching function to that schema.

For example, you have the following statement:

     SELECT PABLO.BLOOP(COLUMN1) FROM T 

Only the BLOOP functions in schema PABLO are considered. It does not matter that user SERGE has defined a BLOOP function, or whether there is a built-in BLOOP function. Now suppose that user PABLO has defined two BLOOP functions in his schema:

     CREATE FUNCTION BLOOP (INTEGER) RETURNS ... 
     CREATE FUNCTION BLOOP (DOUBLE) RETURNS ...

BLOOP is thus overloaded within the PABLO schema, and the function selection algorithm chooses the best BLOOP, depending on the data type of the argument, COLUMN1. In this case, both of the PABLO.BLOOPs take numeric arguments, and if COLUMN1 is not one of the numeric types, the statement will fail. On the other hand if COLUMN1 is either SMALLINT or INTEGER, function selection will resolve to the first BLOOP, while if COLUMN1 is DECIMAL or DOUBLE, the second BLOOP will be chosen.

Several points about this example:

  1. It illustrates argument promotion. The first BLOOP is defined with an INTEGER parameter, yet you can pass it a SMALLINT argument. The function selection algorithm supports promotions among the built-in data types and DB2® performs the appropriate data value conversions.
  2. If for some reason you want to call the second BLOOP with a SMALLINT or INTEGER argument, you need to take an explicit action in your statement as follows:
         SELECT PABLO.BLOOP(DOUBLE(COLUMN1)) FROM T
  3. If you want to call the first BLOOP with a DECIMAL or DOUBLE argument, you have your choice of explicit actions, depending on your intent:
         SELECT PABLO.BLOOP(INTEGER(COLUMN1)) FROM T
         SELECT PABLO.BLOOP(FLOOR(COLUMN1)) FROM T 
Related reference
Use unqualified function reference
Define a UDT