Locate simple large objects in named files
To have locate
the TEXT or BYTE data in a named file, set the loc_loctype field
of the locator structure to LOCFNAME, as shown in the following example:
EXEC SQL BEGIN DECLARE SECTION;
loc_t my_simple_lo;
EXEC SQL END DECLARE SECTION;
;
my_simple_lo.loc_loctype = LOCFNAME;
To use a named file as a simple-large-object location, your program must specify a pointer to the file name in the loc_fname field of the locator structure. You must also set the loc_oflags field with a file-open mode flag to tell how to access the file when it opens it.
To open a named file, opens
the file named in the loc_fname field with the mode flags that
the loc_oflags field specifies. If this file does not exist, creates
it. then
puts the file descriptor of the open file in the loc_fd field
and proceeds as if your program opened the file. If cannot
open this file, it sets the loc_status field (and SQLCODE)
to -461
. When the transfer is complete, closes
the file, which releases the file descriptor in the loc_fd field.
The demo directory contains the following
two sample programs
that demonstrate how to handle simple-large-object data located in
a named file:
- The getcd_nf.ec program selects a simple large object into a named file.
- The updcd_nf.ec program inserts a simple large object from a named file.
These programs assume the stores7 database as the
default database for the simple-large-object data. The user can specify
another database (on the default database server) as a command-line
argument as follows:
getcd_of mystores