Example: Extract a document to a file

This program example shows how character large object (CLOB) elements can be retrieved from a table into an external file.

How the sample LOBFILE program works

  1. Declare host variables. The BEGIN DECLARE SECTION and END DECLARE SECTION statements delimit the host variable declarations. Host variables are prefixed with a colon (:) when referenced in an SQL statement. A CLOB FILE REFERENCE host variable is declared.
  2. CLOB FILE REFERENCE host variable is set up. The attributes of the FILE REFERENCE are set up. A file name without a fully declared path is, by default, placed in the user's current directory. If the path name does not begin with the forward slash (/) character, it is not qualified.
  3. Select into the CLOB FILE REFERENCE host variable. The data from the resume field is selected into the file name that is referenced by the host variable.

The CHECKERR macro/function is an error checking utility which is external to the program. The location of this error checking utility depends on the programming language used:

C
check_error is redefined as CHECKERR and is located in the util.c file.
COBOL
CHECKERR is an external program named checkerr.cbl
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.