The streamread() support function

On a target database server, the streamread() support function converts opaque-type data from its stream representation to its binary representation, which is stored in the target database.

The streamread() support function accepts a stream descriptor and the address of a buffer into which to read the opaque-type data, as the following signature shows:
mi_integer streamread(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 buffer into which the function is to copy the binary representation of the opaque-type data.

The stream buffer is declared with the appropriate format for the binary representation of the opaque-type data. The passing mechanism for this buffer 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 buffers for opaque-type data are passed by reference to streamread() as double pointers.

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

A sample SQL declaration for the streamread() function follows:
CREATE FUNCTION streamread(STREAM, OUT MyUdt)
RETURNS INTEGER
EXTERNAL NAME '/usr/local/udrs/stream/myudt.so(MyUdtStreamRead)'
LANGUAGE C;
Tip: Unlike most opaque-type support functions, the streamread() function for an opaque type must have the explicit name streamread 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 streamread() function.