Skip Headers

# Creating and Using a User-Defined Function

Previous

Next

Different databases sometimes implement the same functions in different ways. For example, an argument that specifies that data returns in ascending order might be ASC or ASCENDING. To manage differences, TopLink recognizes functions and other operators that vary according to the relational database.

Although most platform-specific operators exist in TopLink, if necessary, you can create your own operators.

To create a user-defined function, use the `ExpressionOperator` class.

An `ExpressionOperator` has a selector and a `Vector` of strings:

- The selector is the identifier (id) by which users refer to the function.

- The strings are the constant strings used in printing the function. When printed, the strings alternate with the function arguments.

You can also specify whether the operator is prefix or postfix. In a prefix operator, the first constant string prints before the first argument; in a postfix, it prints afterwards.

Where you create a user-defined function and how you add it to the TopLink expression framework depends on whether you want the new function available to all database platforms or to only a specific database platform.

This section describes the following:

- Making a User-Defined Function Available to a Specific Platform

- Making a User-Defined Function Available to All Platforms