Binary Large Objects (BLOBs), Character Large Objects (CLOBs), and Double Byte Character Large Objects (DBCLOBs), along with the concepts of LOB LOCATORS and LOB FILES are now recognized by the preprocessor. Refer to the DB2 manuals for more information on these subjects,
LOBS, CLOBS, and BLOBS can be as large as 2,147,483,640 bytes long (2 Gigabytes - 8 bytes for PL/I overhead). Double Byte CLOBS can be 1,073,741,820 characters long (1 Gigabyte - 4 characters for PL/I overhead). BLOBS, CLOBS, AND DBCLOBS can be declared in PL/I programs with the following syntax (PL/I variables for Large Object columns, locators, and files):
>>-+-Declare-+--PL/I host identifier----------------------------> '-Dcl-----' >--SQL TYPE IS-| PL/I LOB type |--| PL/I LOB type: |------------> >--+-+-+-Binary Large Object-+----+--(--length--+---+--)-+----->< | | '-BLOB----------------' | +-K-+ | | +-+-Character Large Object-+-+ +-M-+ | | | +-Char Large Object------+ | '-G-' | | | '-CLOB-------------------' | | | '-DBCLOB---------------------' | +-+-BLOB as locator---+-------------------------------+ | +-CLOB as locator---+ | | '-DBCLOB as locator-' | '-+-BLOB as file---+----------------------------------' +-CLOB as file---+ '-DBCLOB as file-'
For example, consider the following declare:
Dcl my-identifier-name SQL TYPE IS lob-type-name (length);
The SQL preprocessor would transform the declare into this structure:
Define structure
1 lob-type-name_length,
2 Length unsigned fixed bin(31),
2 Data(length) char(1);
Dcl my-identifier-name TYPE lob-type-name_length;In this structure, my-identifier-name is the name of your PL/I host identifier and lob-type-name_length is a name generated by the preprocessor consisting of the LOB type and the length.
For DBCLOB data types, the generated structure looks a little different:
Define structure
1 lob-type-name_length,
2 Length unsigned fixed bin(31),
2 Data(length) type wchar_t;In this case, type wchar_t is defined in the include member sqlsystm.cpy. This member must be included to use the DBCLOB data type.
For example, consider the following declare:
Dcl my-identifier-name SQL TYPE IS lob-type AS LOCATOR;
The SQL preprocessor would transform this declare into the following code:
Define alias lob-type_LOCATOR fixed bin(31) unsigned; Dcl my-identifier-name TYPE lob-type_LOCATOR;
In this case, my-identifier-name is your PL/I host identifier and lob-type_LOCATOR is a name generated by the preprocessor consisting of the LOB type and the string LOCATOR.
For example, consider this declare:
Dcl my-identifier-name SQL TYPE IS lob-type AS FILE;
The SQL preprocessor transforms the declare as follows:
Define structure
1 lob-type_FILE,
2 Name_Length unsigned fixed bin(31),
2 Data_Length unsigned fixed bin(31),
2 File_Options unsigned fixed bin(31),
2 Name char(255);
Dcl my-identifier-name TYPE lob-type_FILE;Again, my-identifier-name is your PL/I host identifier and lob-type_FILE is a name generated by the preprocessor consisting of the LOB type and the string FILE.
The following examples provide sample PL/I variable declarations and their corresponding transformations for LOB support.
Dcl my_blob SQL TYPE IS blob(2000);
After transform:
Define structure
1 blob_2000,
2 Length unsigned fixed bin(31),
2 Data(2000) char(1);
Dcl my_blob type blob_2000;
Dcl my_dbclob SQL TYPE IS DBCLOB(1M);
After transform:
Define structure
1 dbclob_1m,
2 Length unsigned fixed bin(31),
2 Data(1048576) type wchar_t;
Dcl my_dbclob type dbclob_1m ;
Dcl my_clob_locator SQL TYPE IS clob as locator;
After transform:
Define alias clob_locator fixed bin(31) unsigned; Dcl my_clob_locator type clob_locator;
Dcl my_blob_file SQL TYPE IS blob as file;
After transform:
Define structure
1 blob_FILE,
2 Name_Length unsigned fixed bin(31),
2 Data_Length unsigned fixed bin(31),
2 File_Options unsigned fixed bin(31),
2 Name char(255);
Dcl my_blob_file type blob_file;
Dcl my_dbclob_file SQL TYPE IS dbclob as file;
After transform:
Define structure
1 dbclob_FILE,
2 Name_Length unsigned fixed bin(31),
2 Data_Length unsigned fixed bin(31),
2 File_Options unsigned fixed bin(31),
2 Name char(255);
Dcl my_dbclob_file type dbclob_file;