The mi_lo_read() function

The mi_lo_read() function reads a specified number of bytes of data from an open smart large object into a buffer.

Syntax

mi_integer mi_lo_read(conn, LO_fd, buf, nbytes)
   MI_CONNECTION *conn;
   MI_LO_FD LO_fd;
   char *buf;
   mi_integer nbytes;
conn
This value is one of the following connection values:

A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().

A NULL-valued pointer (database server only)

LO_fd
An LO file descriptor for the smart large object from which to read the data. It is obtained from a previous call to mi_lo_open().
buf
A pointer to a user-allocated character buffer that contains the data that mi_lo_read() reads from the smart large object.
nbytes
The maximum number of bytes to read into the buf character buffer. This value cannot exceed 2 GB.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_lo_read() function reads nbytes of data from the open smart large object that the LO_fd file descriptor identifies. The read begins at the current LO seek position for LO_fd. You can use the mi_lo_tell() function to obtain the current LO seek position.

The function reads this data into the user-allocated buffer that buf references. The buf buffer must be less than 2 GB in size. To read smart large objects that are larger than 2 GB, read them in 2 GB chunks.

To perform a seek operation before a read operation, use the function mi_lo_readwithseek().

Server only: The mi_lo_read() function does not need a connection descriptor to execute. If your UDR does not need a valid connection for other operations, you can specify a NULL-valued pointer for the conn parameter to establish a NULL connection. For information about the advantages of a NULL connection, see the Informix® DataBlade® API Programmer's Guide.

Return values

>=0
The actual number of bytes that the function has read from the open smart large object to the buf buffer.
MI_ERROR
The function was not successful.