Home | Previous Page | Next Page   Writing Support Functions > Handling the Internal Representation >

The Send and Receive Support Functions

The database server uses the send and receive support functions when it passes data to and from a client application.

The SENDRECV Data Type

The SENDRECV data type holds the external binary representation of an opaque data type when it is transferred between the client computer and the database server computer. The SENDRECV data type allows for any possible change in the size of the data when it is converted between the two representations. The receive and send support functions serve as cast functions between the SENDRECV and opaque data type.

ESQL/C

ESQL/C applications do not use the SENDRECV data type. Instead, these applications use fixed binary and var binary host variables in SQL statements to transfer the internal representation of an opaque type on the client computer. The database server implicitly invokes the receive and send support functions when it receives an SQL statement that contains a fixed binary or var binary host variable.

End of ESQL/C

Receive Support Function

The receive support function converts opaque data from its external binary representation on the client computer to its internal representation on the database server computer and provides an implicit cast from the SENDRECV to the opaque data type.

The database server calls the receive function when it receives the external binary representation of an opaque type from a client application. For example, when a client application issues an INSERT or UPDATE statement, it can send the external binary representation of an opaque type to the database server to be stored in a column.

Figure 13 shows when the database server executes the receive support function.

Figure 13. Execution of the Receive Support Function
begin figure description - This figure is described in the surrounding text. - end figure description

The database server calls the receive function to convert the external binary representation of the client computer to the internal representation of the database server computer, where the opaque type is stored on disk.

C Language Support

The receive function takes as an argument an mi_sendrecv structure (that holds the internal structure on the client computer) and returns the internal structure for the opaque type (the internal representation on the database server computer). The following function signature is for a receive support function of an opaque data type whose internal structure is ll_longlong_t:

ll_longlong_t * ll_longlong_receive(mi_sendrecv
*client_intrnl_format);

The ll_longlong_receive() function is a cast function from the SENDRECV data type to the ll_longlong_t internal structure. It must be registered as an implicit cast function with the CREATE IMPLICIT CAST statement. For more information on cast functions, see Creating Casts for Opaque Data Types.

End of C Language Support

Send Support Function

The database server calls the send function when it sends the external binary representation of an opaque type to a client application. For example, when a client application issues a SELECT or FETCH statement, it can save the data of an opaque type that it receives from the database server in a host variable that conforms to the external binary representation of the opaque type.

Figure 14 shows when the database server executes the send support function.

Figure 14. Execution of the Send Support Function
begin figure description - This figure is described in the surrounding text. - end figure description

The database server calls the send function to convert the internal representation that is stored on disk to the external binary representation that the client computer uses.

C Language Support

The send function takes as an argument the internal structure for the opaque type on the database server computer and returns an mi_sendrecv structure that holds the internal structure on the client computer. The following function signature is for a send support function of an opaque data type whose internal structure is ll_longlong_t:

mi_sendrecv * ll_longlong_send(ll_longlong_t *srvr_intrnl_format);

The ll_longlong_send() function is a cast function from the ll_longlong_t internal structure to the SENDRECV data type. It must be registered as an explicit cast function with the CREATE EXPLICIT CAST statement. For more information on cast functions, see Creating Casts for Opaque Data Types.

End of C Language Support
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]