The getcd_nf sample program from the demo directory
shows how to select a simple large object from the database into a
named file. The following code excerpt prompts the user to enter a
catalog number for the catalog table and the name of the file
to which the program writes the contents of the cat_descr column
for that row. The program stores the name of the file in the descfl array.
It then executes a SELECT statement to read the cat_descr TEXT
column from the catalog table and write it to a file that the
user specifies in response to a prompt.
The following figure shows a code excerpt from the getcd_nf sample
program.
The program sets the cat_descr locator structure
fields as follows:
The loc_loctype field contains LOCFNAME to tell to
place the text for the cat_descr column in a named file.
The loc_fname field is the address of the descfl array
to tell to
write the contents of the cat_descr column to the file named
in descfl.
The loc_oflags field, the file-open mode flags, is set
to LOC_APPEND to tell to
append selected data to the existing file.
The getcd_nf program then executes the SELECT statement
to retrieve the row. After writes
data to the named file, it sets the following fields of the locator
structure:
The loc_size field contains the number of bytes written
to the file. If the program
fetches a null (or empty) simple-large-object column into a named
file that exists, it truncates the 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.
Have feedback?
Google Analytics is used to store comments and ratings. To provide a comment or rating for a topic, click Accept All Cookies or Allow All in Cookie Preferences in the footer of this page.