+ (binary)
plus()
- (binary)
minus()
*
times()
/
divide()
+ (unary)
positive()
- (unary)
negate()
When an SQL statement contains an arithmetic operator, the database server automatically invokes the associated operator function. All operator functions in Figure 2-4 except positive() and negate() take two arguments; the positive() and negate() functions take only one argument. All these operator functions can return any data type.
Text Operators Universal Server also provides operator functions for the text operators that Figure 2-5 shows.
LIKE
like()
MATCHES
matches()
||
concat()
When an SQL statement contains a text operator, the database server automatically invokes the associated operator function. The like() and matches() functions take two or three arguments and must return a Boolean value. The concat() function takes two arguments and can return any data type. For information on syntax and use of the LIKE and MATCHES operators, see the description of the Condition segment in the Informix Guide to SQL: Syntax.
Relational Operators Universal Server provides operator functions for the relational operators that Figure 2-6 shows.
=
equal()
<> and !=
notequal()
>
greaterthan()
<
lessthan()
>=
greaterthanorequal()
<=
lessthanorequal()
When an SQL statement contains a relational operator, the database server automatically invokes the associated operator function. All operator functions in Figure 2-6 take two arguments and must return a Boolean value. For more information on relational operators, see the description of the Relational Operator segment in the Informix Guide to SQL: Syntax.
For end users to be able to use values of a new data type with relational operators, you must write new relational-operator functions that can handle the new data type. In these functions, you can:
Built-In Functions Universal Server provides special SQL-invoked functions, called built-in functions, that provide some basic mathematical operations. Figure 2-7 shows the built-in functions that you can overload.
Figure 2-4 needs to be reviewed!!
Figure 2-7 Built-In Functions That You Can Overload (1 of 2) Built-In Function Number of Parameters Parameter Types abs() 1 real number mod() 2 integer-number expression, integer-number expression pow() 2 real-number expression, real-number expression root() 1 or 2 real-number expression[, real-number expression] round() 1 or 2 expression[, literal integer] sqrt() 1 real-number expression trunc() 1 or 2 expression[, literal integer] exp(), log(), logn() 1 positive real-number expression cos(), sin(), tan() 1 numeric expression acos(), asin(), atan() 1 numeric expression atan2() 2 numeric expression, numeric expression hex() 1 integer expression length(), char_length(), character_length(), octet_length() 1 character string user() 0 None current() 0 None dbservername(), sitename() 0 None today() 0 None extend() 1 date/time expression The following table lists the built-in functions you cannot overload.
(1 of 2)
abs()
1
real number
mod()
2
integer-number expression, integer-number expression
pow()
real-number expression, real-number expression
root()
1 or 2
real-number expression[, real-number expression]
round()
expression[, literal integer]
sqrt()
real-number expression
trunc()
exp(), log(), logn()
positive real-number expression
cos(), sin(), tan()
numeric expression
acos(), asin(), atan()
atan2()
numeric expression, numeric expression
hex()
integer expression
length(), char_length(), character_length(), octet_length()
character string
user()
0
None
current()
dbservername(), sitename()
today()
extend()
date/time expression
cardinality()
month()
date()
trim()
day()
weekday()
dbinfo()
year()
mdy()
descr()
volume()
family()
Universal Server provides versions of the built-in functions that handle the built-in data types. You can write a new version of a built-in function to allow the function to operate on your new opaque data type. If you write a new version of a built-in function, make sure you follow these rules:
Aggregate Functions The database server provides special SQL-invoked functions, called aggregate functions, that take values that depend on all the rows that the query selects; they return information about these values, not the actual values themselves. Universal Server provides the following aggregate functions:
End-User Routines The database server provides special SQL-invoked functions and procedures, called end-user routines, that implement tasks you define for end users to use in expressions of SQL statements. These routines provide additional functionality that an end user might need to work with an existing or new data type. An end-user routine can be either of the following: