The streamwrite() support function

On a destination database server, the streamwrite() support function converts opaque-type data from its binary representation to its stream representation.

The streamwrite() support function accepts a stream descriptor and the address of opaque-type data to write, as the following signature shows:
mi_integer streamwrite(strm_desc, binary_rep)
   MI_STREAM *strm_desc;
   my_opq_type *binary_rep;
strm_desc
A pointer to a stream descriptor for an open stream. For more information, see Access to a stream (Server).
binary_rep
A pointer to the binary representation of the opaque-type data, which is written to the stream.

The binary representation is the appropriate format for the opaque-type data. The passing mechanism for this data depends on the kind of opaque type, as Input support function for circle opaque type through Input support function for image opaque type show. Most opaque-type values are passed by reference to the streamwrite() function as single pointers.

The streamwrite() function returns the number of bytes written to the stream or MI_ERROR. This function can also return the errors that mi_stream_write() returns. To convert the individual fields of the opaque-type internal representation to their stream representation, streamwrite() can call the stream-write functions of the DataBlade API (see Convert opaque-type data between stream and binary representations).

A sample SQL declaration for the streamwrite() function follows:
CREATE FUNCTION streamwrite(STREAM, MyUdt)
RETURNS INTEGER
EXTERNAL NAME '/usr/local/udrs/stream/myudt.so(MyUdtStreamWrite)'
LANGUAGE C; 
Tip: Unlike most opaque-type support functions, the streamwrite() function for an opaque type must have the explicit name streamwrite when you register it with the CREATE FUNCTION statement. It is recommended that you include the name of the opaque type in the C-language version of its streamwrite() function.