DB2 Developers Guide (5th Edition)

 <  Day Day Up  >  

Data Type

Physical Storage

Value Range

COBOL Picture

SMALLINT

2 bytes

“32,768 to +32,767

PIC S9(4) COMP

INTEGER

4 bytes

“2,147,483,648 to +2,147,483,647

PIC S9(9) COMP

REAL

4 bytes

5.4E “79 to 7.2E+75

PIC USAGE COMP-1

FLOAT(1..21)

4 bytes

5.4E “79 to 7.2E+75

PIC USAGE COMP-1

DOUBLE PRECISION

8 bytes

5.4E “79 to 7.2E+75

PIC USAGE COMP-2

FLOAT(22..53)

8 bytes

5.4E “79 to 7.2E+75

PIC USAGE COMP-2

DECIMAL( m,n )

( m /2)+1 bytes

1 “10 31 to 10 31 “1

PIC S9( m - n )V9( n ) COMP-3

CHARACTER( n )

n bytes

254 chars maximum

PIC X( n )

VARCHAR( n )

2 to n +2 bytes

4,046 bytes maximum 32,704 for 32KB pages

01 VARCHAR. 49 LTH PIC S9(4)COMP. 49 COLUMN PIC X( n ).

GRAPHIC( n )

2 n bytes

127 double-byte characters maximum

PIC G( n ) DISPLAY-1

VARGRAPHIC( n )

2 to 2 n +2 bytes

2,023 double-byte characters maximum 32,704 for 32KB pages

01 VGRAPHIC. 49 LENGTH PIC S9(4) 49 COLUMN PIC G(n) DISPLAY-1

DATE

4 bytes

0001-01-01 to 9999-12-31

PIC X(10)

TIME

3 bytes

00.00.00 to 24.00.00

PIC X(8)

TIMESTAMP

10 bytes

0001-01-01.00.00.00.000000 to 9999-12-31.24.00.00.000000

PIC X(26)

ROWID

up to 40 bytes

internal identifier

01 ROWID-VAR USAGE IS SQL USAGE IS ROWID

BLOB

varies

up to 2GB

01 BLOB-VAR USAGE IS SQL TYPE IS BLOB( n ).

- or -

   

01 BLOB-LOC USAGE IS SQL TYPE IS BLOB-LOCATOR.

CLOB

varies

up to 2GB

01 CLOB-VAR USAGE IS SQL TYPE IS CLOB( n ).

- or -

   

01 CLOB-LOC USAGE IS SQL TYPE IS CLOB-LOCATOR.

DBCLOB

varies

up to 2GB

01 DBCLOB-VAR USAGE IS SQL TYPE IS DBCLOB( n ).

- or -

   

01 DBCLOB-LOC USAGE IS SQL TYPE IS DBCLOB-LOCATOR.

NOTE

Applications that access or manipulate LOB data require either declared host variables to hold the LOB data or LOB locator variables to point to the LOB data.

DB2 will generate a PIC S9(9) USAGE IS BINARY field to be used for LOB locators defined as shown earlier.

For BLOB, CLOB, and DBCLOB, host variables defined for DB2 will generate a field structure to hold the LOB data. The first component is a PIC 9(9) COMP field to hold the length of the LOB, followed by the declaration for the actual LOB data. But the largest character and graphic variable declaration permitted in a COBOL program is 32,767 bytes. So, for LOBs greater than 32,767 bytes, DB2 will create multiple host language declarations of 32,767 or fewer bytes.

 <  Day Day Up  >  

Категории