Identify support functions

The following table summarizes the support functions for opaque data types.
Function Purpose Reference
input Converts opaque data from its external text representation to its internal representation. Supports insertion of data in text format into a column of the opaque type. Requires an implicit cast from the LVARCHAR data type to opaque data type. Input support function
output Converts opaque data from its internal representation to its external text representation. Supports selection of data from a column of the opaque type in its external text format. Requires an explicit cast from the opaque data type to LVARCHAR opaque data type. Output support function
receive Converts opaque data from its external binary representation on the client computer to its internal representation on the database server computer. Supports insertion of binary data into a column of the opaque type. Requires an implicit cast from the SENDRECV data type to the opaque data type. Receive support function
send Converts opaque data from its internal representation on the database server computer to its external binary representation on the client computer. Supports selection of binary data from a column of the opaque type. Requires an explicit cast from the opaque data type to the SENDRECV data type. Send support function
import Performs processing of opaque data for bulk load of text data in a column of the opaque type. Requires an implicit cast from the IMPEXP to the opaque data type. Import support function
export Performs processing of opaque data for bulk unload of text data from a column of the opaque type. Requires an explicit cast from the opaque to the IMPEXP data type. Export support function
importbinary Performs processing of opaque data for bulk load of binary data in a column of the opaque type. Requires an implicit cast from the IMPEXPBIN to the opaque data type. Importbinary support function
exportbinary Performs processing of opaque data for bulk unload of binary data from a column of the opaque type. Requires an explicit cast from the opaque to the IMPEXPBIN data type. Exportbinary support function
streamread Converts opaque data from its stream representation to its database server internal representation.
streamwrite Converts opaque data from its internal representation on the database server to its stream representation.
assign Performs any processing required before the database server stores opaque data to disk. Supports storage of opaque data for INSERT, UPDATE, and LOAD statements. The assign() function
destroy Performs any processing necessary before the database server removes a row that contains an opaque data type. The destroy() function
lohandles Returns a list of the embedded large-object handles in the opaque data type. Handle smart large objects
compare Supports opaque data types during ORDER BY, UNIQUE, DISTINCT, and UNION clauses, and BETWEEN comparisons. Also supports CREATE INDEX for B-tree indexes. Compare data
deepcopy Supports multirepresentational data types as function return values The deepcopy() function
update Supports in-place update on smart large objects The update() function

Most support functions can have arbitrary names. The database server identifies a support function by the task that it needs to perform. For example, if the client binds a binary value to INSERT, the database server looks for a cast function in the syscasts system catalog table that converts the UDT value from its external binary format (SENDRECV) to the opaque data type.

The following functions must be named explicitly: compare(), assign(), destroy(), update() and deepcopy(). However, the names are not case sensitive. That is, you can name the function compare() or Compare().

It is recommended that you give your support functions names that help document the purpose of the function. For example, if your opaque data type is named sphere, you might name the receive and send functions sphere_receive() and sphere_send().

Whenever possible, you should create the support functions as NOT VARIANT for better performance. For information about variant and non-variant functions, refer to Return a variant or nonvariant value.