An SQL-invoked function is a user-defined function that an end user can explicitly call in an SQL statement. You might write SQL-invoked functions to extend the functionality of an opaque data type in the following ways:
The SQL functions that the database server defines handle the built-in data types. For a UDT to use any of these functions, you can overload the function that handles the UDT. For more information on the details of writing user-defined functions, see Developing a User-Defined Routine. For information about overloading functions, refer to Overloading Routines.
The database server supports the following types of SQL-invoked functions that allow you to operate on data in expressions of SQL statements:
The database server also supports the following types of functions that allow you to compare data in expressions of SQL statements:
The database server provides operator functions for arithmetic operators (see Arithmetic Operators) and text operators (see Text Operators). The operator functions that the database server provides handle the built-in data types. You can overload an operator function to provide the associated operation on your new opaque data type.
If you overload an operator function, make sure you follow these rules:
The database server provides special SQL-invoked functions, called built-in functions, that provide some basic mathematical operations. The built-in functions that the database server provides handle the built-in data types. You can overload a built-in function to provide the associated operation on your new opaque data type. If you overload a built-in function, follow these rules:
For more information on built-in functions, see the IBM Informix: Guide to SQL Syntax.
You can extend the built-in aggregate functions, such as SUM and AVG, to operate on your opaque data type. You can also create new aggregates. Creating User-Defined Aggregates, describes how to extend or create aggregates.
The database server supports the following relational operators on an opaque data type in the conditional clause of SQL statements:
For more information on the conditional clause, see the Condition segment in the IBM Informix: Guide to SQL Syntax. For more information on the compare() function, see Comparison Function for Opaque Data Types.
The database server provides operator functions for the relational operators listed in Relational Operators. The relational-operator functions that the database server provides handle the built-in data types. You can overload a relational-operator function to provide the associated operation on your new opaque data type.
If you overload a relational-operator function, make sure you follow these rules:
You must define an equal() function to handle your opaque data type if you want to allow columns of this data type to be:
For more information on constraints, see the CREATE TABLE statement in the IBM Informix: Guide to SQL Syntax.
The database server uses a built-in bit-hashing function to produce the hash value for a data type, which means that the built-in hash function can be used only for bit-hashable data types. If your opaque data type is not bit hashable, the database server cannot use its built-in hash function for the equality comparison. Therefore, if your data type is not bit-hashable, you cannot use it in the following cases:
For opaque types that are not bit hashable using the built-in hashing function of the database server, specify the CANNOTHASH modifier in the CREATE OPAQUE TYPE statement.
Hashable data types have the following property: if A = B, then hash(A) = hash(B), which means that A and B have identical bit representations.
Multirepresentational data types are not bit hashable because they store large quantities of data in a smart large object and then store the large object handle in the user-defined type. It is the smart-large-object handle that makes the multirepresentational data type nonhashable. That is, the CREATE OPAQUE TYPE statement for a multirepresentational data type must include the CANNOTHASH modifier.
The compare() function is an SQL-invoked function that sorts the target data type. The database server uses the compare() function to execute the following clauses and keywords of the SELECT statement:
The database server also uses the compare() function to evaluate the BETWEEN operator in the condition of an SQL statement. For more information on conditional clauses, see the Condition segment in the IBM Informix: Guide to SQL Syntax.
The database server provides compare() functions that handle the built-in data types. For the database server to be able to sort an opaque data type, you must define a compare() function to handle this opaque data type.
If you define a compare() function, you must also define the greaterthan(), lessthan(), equal or other functions that use the compare function.
If you overload the compare() function, make sure you follow these rules:
The compare() function is also the support function for the default operator class of the B-tree secondary-access method. For more information, see Generic B-Tree Index.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]