Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

Large Object (LOB) support

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,

General information on LOBs

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):

Read syntax diagramSkip visual syntax diagram>>-+-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-'
 
BLOB, CLOB, and DBCLOB data types
The variable declarations for BLOBs, CLOBs, and DBCLOBs are transformed by the PL/I SQL preprocessor.

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.

length
The length field is an unsigned integer that maps to a fixed binary. The values of the length field can range from 0 to (2**32)-8. If the length field is appended by a K, M, or G, then the length is calculated by the preprocessor.
BLOB, CLOB, and DBCLOB LOCATOR data types
The variable declarations for BLOB, CLOB, and DBCLOB locators are also transformed by the PL/I SQL preprocessor.

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.

BLOB, CLOB, and DBCLOB FILE data types
The variable declarations for BLOB, CLOB, and DBCLOB files are also transformed by the PL/I SQL preprocessor.

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.

PL/I variable declarations for LOB Support

The following examples provide sample PL/I variable declarations and their corresponding transformations for LOB support.

Example 1
  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;
Example 2
  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 ;
Example 3
  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;
Example 4
  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;
Example 5
  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;

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)