Declaration of large object type host variables in COBOL embedded SQL applications

Large object (LOB) type host variables that you declare in your embedded COBOL application are treated as if they were declared in a COBOL program. You can use host variables to exchange data between the embedded application and the database manager.

The syntax for declaring large object (LOB) host variables in COBOL is:

Read syntax diagramSkip visual syntax diagram01variable-nameUSAGEISSQL TYPE ISBLOBCLOBDBCLOB(length KMG ).
LOB host variable considerations:
  1. For BLOB and CLOB 1 <= lob-length <= 2 147 483 647.
  2. For DBCLOB 1 <= lob-length <= 1 073 741 823.
  3. SQL TYPE IS, BLOB, CLOB, DBCLOB, K, M, G can be in either uppercase, lowercase, or mixed.
  4. Initialization within the LOB declaration is not permitted.
  5. The host variable name prefixes LENGTH and DATA in the precompiler generated code.

BLOB example:

Declaring:
     01 MY-BLOB USAGE IS SQL TYPE IS BLOB(2M). 
Results in the generation of the following structure:
     01 MY-BLOB. 
        49 MY-BLOB-LENGTH PIC S9(9) COMP-5. 
        49 MY-BLOB-DATA PIC X(2097152). 

CLOB example:

Declaring:
    01 MY-CLOB USAGE IS SQL TYPE IS CLOB(125M). 
Results in the generation of the following structure:
    01 MY-CLOB. 
       49 MY-CLOB-LENGTH PIC S9(9) COMP-5. 
       49 MY-CLOB-DATA PIC X(131072000). 

DBCLOB example:

Declaring:
    01 MY-DBCLOB USAGE IS SQL TYPE IS DBCLOB(30000). 
Results in the generation of the following structure:
    01 MY-DBCLOB. 
       49 MY-DBCLOB-LENGTH PIC S9(9) COMP-5. 
       49 MY-DBCLOB-DATA PIC G(30000) DISPLAY-1.