LOB host variables in PL/I applications that use SQL

PL/I does not have variables that correspond to the SQL data types for LOBs (large objects). To create host variables that can be used with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces this declaration with a PL/I language structure in the output source member.

The following figure shows the syntax for valid LOB host variables.

LOB

Read syntax diagramSkip visual syntax diagram
>>-+-DECLARE-+--+-variable-name-----------+--------------------->
   '-DCL-----'  |    .-,-------------.    |   
                |    V               |    |   
                '-(----variable-name-+--)-'   

>--SQL TYPE IS--+-CLOB-+--(--lob-length--+---+--)--;-----------><
                '-BLOB-'                 '-K-'         

Notes:
  1. For BLOB and CLOB, 1 ≤ lob-length ≤ 32,766
  2. SQL TYPE IS, BLOB, CLOB can be in mixed case.

CLOB Example

The following declaration:

DCL MY_CLOB SQL TYPE IS CLOB(16384);

Results in the generation of the following structure:

DCL 1 MY_CLOB,
      3 MY_CLOB_LENGTH BINARY FIXED (31) UNALIGNED,
      3 MY_CLOB_DATA CHARACTER (16384);

BLOB Example

The following declaration:

DCL MY_BLOB SQL TYPE IS BLOB(16384);

Results in the generation of the following structure:

DCL 1 MY_BLOB,
      3 MY_BLOB_LENGTH BINARY FIXED (31) UNALIGNED,
      3 MY_BLOB_DATA CHARACTER (16384);

The following figure shows the syntax for valid LOB locators.

LOB locator

Read syntax diagramSkip visual syntax diagram
>>-+-DECLARE-+--+-variable-name-----------+--------------------->
   '-DCL-----'  |    .-,-------------.    |   
                |    V               |    |   
                '-(----variable-name-+--)-'   

>--SQL TYPE IS--+-CLOB_LOCATOR---+--;--------------------------><
                +-DBCLOB_LOCATOR-+      
                '-BLOB_LOCATOR---'      

Note: SQL TYPE IS, BLOB_LOCATOR, CLOB_LOCATOR, DBCLOB_LOCATOR can be in mixed case.

CLOB Locator Example

The following declaration:

DCL MY_LOCATOR SQL TYPE IS CLOB_LOCATOR;

Results in the following generation:

DCL MY_LOCATOR BINARY FIXED(31) UNALIGNED;

BLOB and DBCLOB locators have similar syntax.

The following figure shows the syntax for valid LOB file reference variables.

LOB file reference variable

Read syntax diagramSkip visual syntax diagram
>>-+-DECLARE-+--+-variable-name-----------+--------------------->
   '-DCL-----'  |    .-,-------------.    |   
                |    V               |    |   
                '-(----variable-name-+--)-'   

>--SQL TYPE IS--+-CLOB_FILE---+--;-----------------------------><
                +-DBCLOB_FILE-+      
                '-BLOB_FILE---'      

Note: SQL TYPE IS, BLOB_FILE, CLOB_FILE, and DBCLOB_FILE can be in mixed case.

CLOB File Reference Example

The following declaration:

DCL MY_FILE SQL TYPE IS CLOB_FILE;

Results in the generation of the following structure:

DCL 1 MY_FILE,
      3 MY_FILE_NAME_LENGTH BINARY FIXED(31) UNALIGNED,
      3 MY_FILE_DATA_LENGTH BINARY FIXED(31) UNALIGNED,
      3 MY_FILE_FILE_OPTIONS BINARY FIXED(31) UNALIGNED,
      3 MY_FILE_NAME CHAR(255);

BLOB and DBCLOB locators have similar syntax.

The pre-compiler will generate declarations for the following file option constants:

Related information
LOB file reference variables