INFORMIX
Extending INFORMIX-Universal Server: User-Defined Routines
Chapter 2: Routine Overloading and Routine Resolution
Home Contents Index Master Index New Book

Operator-to-Function Binding

Operator binding is the implicit invocation of an operator function (such as equal) when an operator symbol (such as =) is used in an SQL statement with user-defined data types.

This implicit mapping of operator function names to built-in operators facilitates writing SQL expressions with user-defined data types. When you overload an operator function, the SQL user does not need to specify anything different in the SQL statement. The SQL user can invoke the routine with an argument on either side of the operator symbol, as is normally done with built-in data types.

For example, the following sample SQL statements show how you can invoke the equal function for a new data type, ScottishName, that treats the strings "Mc" and "Mac" the same:

The SQL user does not need to invoke the user-defined equal function as in the following example:

Figure 2-8 lists the operator symbol and the built-in function name to which the database server maps implicitly.

Figure 2-8
Operator-Symbol To Operator-Function Binding

(1 of 2)

Operator Symbol Operator Function Number of Arguments Return Type

=

equal

2

Boolean

<>,!=

notequal

2

Boolean

>

greaterthan

2

Boolean

<

lessthan

2

Boolean

>=

greaterthanorequal

2

Boolean

<=

lessthanorequal

2

Boolean

like

like

2 or 3

Boolean

matches

matches

2 or 3

Boolean

-

minus

2

Any type

+

plus

2

Any type

/

divide

2

Any type

*

times

2

Any type

||

concat

2

Any type

+

positive

1

Any type

-

negate

1

Any type




Extending INFORMIX-Universal Server: User-Defined Routines, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.