The example shows the code for the lld_copy_subset user-defined
routine. This routine copies a portion of a large object and appends
it to another large object.
The lld_copy_subset function defines four
parameters:
A source large object (lld_locator type)
A destination large object (lld_locator type)
The byte offset to begin copying
The number of bytes to copy
It returns an lld_locator, identifying the object being
appended.
The mi_open function opens a connection
to the database. A buffer is allocated for I/O.
The following Large Object Locator functions
are called for the source object:
lld_open
OpenS the source object
lld_seek
Seeks to the specified byte offset in the object
lld_read
Reads the specified number of bytes from the object
lld_close
Closes the object
The following Large Object Locator functions
are called for the destination object:
lld_open, to open the destination object
lld_write, to write the bytes read from the source into
the destination object
lld_close, to close the destination object
The mi_close function closes the database
connection.
This function also contains error-handling code.
If the database connection cannot be made, if memory cannot be allocated,
or if any of the Large Object Locator functions
returns an error, the error code is invoked.
The error code handling code (bad) does
one or more of the following actions, if necessary:
Closes the source file
Deletes the destination file
Frees the buffer
Closes the database connection
Raises an error
You should establish a callback for exceptions (this example
code, in the interest of simplicity and clarity, does not do so).
See the HCL OneDB™
DataBlade® API Programmer's
Guide for
more information.