LOB file reference variables in ILE RPG applications that use SQL

Here is an example of a CLOB file reference variable in ILE RPG. BLOB and DBCLOB file reference variables have similar syntax.

CLOB file reference example

  • The following declaration in free-form:
      DCL-S MY_FILE SQLTYPE(CLOB_FILE);

    results in the generation of the following structure:

      DCL-DS MY_FILE;                             
        MY_FILE_NL UNS(10);                       
        MY_FILE_DL UNS(10);                       
        MY_FILE_FO UNS(10);                       
        MY_FILE_NAME CHAR(255); 
      END-DS MY_FILE;                             
  • The following declaration in fixed-form:
      D MY_FILE         S          SQLTYPE(CLOB_FILE)

    results in the generation of the following structure:

      D MY_FILE          DS
      D MY_FILE_NL                      10U
      D MY_FILE_DL                      10U
      D MY_FILE_FO                      10U
      D MY_FILE_NAME                   255A
Notes:
  1. LOB file reference variables are allowed to be declared in host structures.
  2. SQLTYPE, BLOB_FILE, CLOB_FILE, DBCLOB_FILE can be in mixed case.
  3. SQLTYPE must be between positions 44 to 80 for fixed-form declarations.
  4. When a LOB file reference is declared as a standalone host variable, position 24 must contain the character 'S' and position 25 must be blank for fixed-form declarations.
  5. The standalone field indicator 'S' in position 24 for fixed-form declarations should be omitted when a LOB file reference variable is declared in a host structure.
  6. LOB file reference variables cannot be initialized.

The pre-compiler will generate declarations for the following file option constants. You can use these constants to set the xxx_FO variable when you use file reference host variables.

  • SQFRD (2)
  • SQFCRT (8)
  • SQFOVR (16)
  • SQFAPP (32)