The mi_lo_from_file_by_lofd() function
The mi_lo_from_file_by_lofd() function copies the contents of an operating-system file on the server or client computer to an open smart large object.
Syntax
mi_integer mi_lo_from_file_by_lofd(conn, LO_fd, fname_spec, open_mode,
offset, amount)
MI_CONNECTION *conn;
MI_LO_FD LO_fd;
const char *fname_spec;
mi_integer open_mode;
mi_integer offset;
mi_integer amount;
- conn
- This 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
- A file descriptor for an existing smart large object
- fname_spec
- The path to the operating-system file to copy into a smart large object.
- open_mode
- An integer bitmask to indicate how to open the operating-system file and where this file is located. For a list of valid file-mode constants, see the following “Usage” section.
- offset
- The point to begin reading in the file. The offset value
is the number of bytes from the beginning of the file, starting at
0
. - amount
- The amount of data to read, starting at the offset. An amount value
of
-1
means read to the end of the file.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
No | Yes |
Usage
The mi_lo_from_file_by_lofd() function
enables you to write to a smart large object that is already open.
This function provides more flexibility than mi_lo_from_file() in
the following ways:
- You can position the LO file descriptor anywhere before the operation.
- You can copy multiple files to a single smart large object.
To include environment variables in the fname_spec path,
use the following syntax:
$ENV_VAR
You must set these environment variables in the database server environment, before the database server starts.
The mi_lo_from_file_by_lofd() function
can create the target files on either the server or the client computer.
The file-mode flag values for the open_mode argument indicate
the location of the file to copy and the access mode of the source
file. Valid values include the following file-mode constants.
- MI_O_EXCL
- Open the file only if fname_spec does not exist.
- MI_O_TRUNC
- Zero out the input file before reading it.
- MI_O_APPEND
- Allow appending to the end of the file. (This function does not write to the source file.)
- MI_O_RDWR
- Open the file in read/write mode. (This function does not write to the source file.)
- MI_O_RDONLY
- Open the file in read-only mode.
- MI_O_TEXT
- Process the file as text (not binary). (Binary is used if you do not specify MI_O_TEXT.)
- MI_O_SERVER_FILE
- The fname_spec file is on the server computer.
- MI_O_CLIENT_FILE
- The fname_spec file is on the client computer.
Important: The MI_O_TRUNC flag is valid
but is not often useful in a DataBlade®
API module.
The
default open_mode value is:
MI_O_RDONLY | MI_O_CLIENT_FILE
Server only: The mi_lo_from_file_by_lofd() 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 HCL OneDB™
DataBlade API Programmer's
Guide.
Return values
- MI_OK
- The function was successful.
- MI_ERROR
- The function was not successful.