User-Defined Functions in Fragment Expressions

For rows that include user-defined data types, you can use comparison conditions or user-defined functions to define the range rules. In the following example, comparison conditions define the range rules for the long1 column, which contains an opaque data type:
FRAGMENT BY EXPRESSION
   long1 < '3001' IN dbsp1,
   long1 BETWEEN '3001' AND '6000' IN dbsp2,
   long1 > '6000' IN dbsp3;

An implicit, user-defined cast converts 3001 and 6000 to the opaque type.

Alternatively, you can use user-defined functions to define the range rules for the opaque data type of the long1 column:
FRAGMENT BY EXPRESSION
   (lessthan(long1,'3001')) IN dbsp1,
   (greaterthanorequal(long1,'3001') AND 
   lessthanorequal(long1,'6000')) IN dbsp2,
   (greaterthan(long1,'6000')) IN dbsp3;

Explicit user-defined functions require parentheses around the entire fragment expression before the IN clause, as the previous example shows.

User-defined functions in a fragment expression can be written in SPL or in the C or Java language. These functions must satisfy four requirements:
  • They must evaluate to a Boolean value.
  • They must be nonvariant.
  • They must reside within the same database as the table.
  • They must not generate OUT nor INOUT parameters.

For information on how to create UDRs for fragment expressions, refer to Informix® User-Defined Routines and Data Types Developer's Guide.