The mi_lo_copy() function
The mi_lo_copy() function creates a copy of a smart large object and opens the copy.
Syntax
MI_LO_FD mi_lo_copy(conn, src_LOhdl, LO_spec, open_mode, target_LOhdl_dptr)
MI_CONNECTION *conn;
MI_LO_HANDLE *src_LOhdl;
MI_LO_SPEC *LO_spec;
mi_integer open_mode;
MI_LO_HANDLE **target_LOhdl_dptr;
- 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)
- src_LOhdl
- A pointer to the LO handle for the existing smart large object that is to be copied.
- LO_spec
- A pointer to the LO-specification structure that contains the storage characteristics to use for the new smart large object.
- open_mode
- An integer bitmask that specifies the open mode for the new smart large object that target_LOhdl_dptr references.
- target_LOhdl_dptr
- A doubly indirected pointer to the target LO handle that identifies
the new smart large object where mi_lo_copy() copies
the data in the smart large object that src_LOhdl references.
Valid in client LIBMI application? Valid in user-defined routine? Yes Yes
Usage
- It obtains an LO handle for the new smart large object and assigns
a pointer to the LO handle that target_LOhdl_dptr references.
If the target_LOhdl_dptr value points to NULL, mi_lo_copy() allocates a new LO handle for the new smart large object and assigns a pointer to this handle to target_LOhdl_dptr. If target_LOhdl_dptr does not point to NULL, mi_lo_copy() assumes that you have already allocated an LO handle and uses the target_LOhdl_dptr argument as a pointer to an existing LO handle.
- It assigns the storage characteristics from the LO-specification
structure, LO_spec, to the new smart large object.
If the LO-specification structure has not been updated with storage characteristics (the associated fields are null), the mi_lo_copy() function uses the system-specified storage characteristics.
If the LO-specification structure was updated with storage characteristics, mi_lo_copy() uses the storage characteristics that the LO-specification structure defines for the new smart large object.
- It opens the new smart large object in the open mode that the open_mode argument
specifies.
The bit mask value for the open_mode argument indicates the open mode of the smart large object after mi_lo_copy() successfully completes. For more information about valid open-mode flags, see the HCL OneDB™ DataBlade® API Programmer's Guide.
- It copies the contents of the data in the smart large object that src_LOhdl references
into the new smart large object that target_LOhdl_dptr references.
The mi_lo_copy() function writes the source data to the sbspace of the new smart large object.
- It returns an LO file descriptor that identifies the new smart
large object and is positioned at the start of this smart large object.
When the mi_lo_copy() function is successful, it returns a valid LO file descriptor. You can then use this file descriptor to identify which smart large object to access in subsequent function calls, such as mi_lo_read() and mi_lo_write().
The mi_lo_copy() function is a constructor function for both an LO file descriptor and an LO handle.
Each mi_lo_copy() call is implicitly associated with the current session. When this session ends, the database server deallocates any smart large objects that mi_lo_copy() has created if its LO handle has not been stored in a column (its reference count is zero) and no open LO file descriptors exist for the smart large object.
Return values
- An MI_LO_FD value
- The LO file descriptor for the open smart large object that target_LOhdl_dptr references. The function also initializes the LO handle that target_LOhdl_dptr references.
- MI_ERROR
- The function was not successful.