Select a simple large object into an open file
The getcd_of sample program from the demo directory
shows how to select a simple large object from the database into an
open file. The following figure shows a code excerpt that selects
the cat_descr column into a file that the user specifies.
To prepare the locator structure for the SELECT statement,
the getcd_of program sets the cat_descr locator structure
fields as follows:
- The loc_loctype field is set to LOCFILE to tell to place the text for the cat_descr column in the open file.
- The loc_fd field is set to the fd file descriptor to identify the open file.
- The loc_oflags field is set to LOC_APPEND to specify that the data is to be appended to any data that exists in the file.
To access the file descriptor (loc_fd) field of
the locator structure, the getcd_of program uses the name cat_descr.loc_fd.
However, the actual name of this field in the locator structure is
as follows:
cat_descr.lc_union.lc_file.lc_fd
The shortcut name of loc_fd is defined as a macro in the locator.h file.
After writes
data to an open file, it sets the following fields of the locator
structure:
- The loc_size field contains the number of bytes written to the open file.
- The loc_indicator field contains
-1
if the selected simple-large-object value is null. - The loc_status field contains the status of the operation:
0
for success and a negative value if an error has occurred. For possible causes of the error, see Error returns in loc_status.