01 DESCR.
49 DESCR-LEN PIC S9(4) COMP-4.
49 DESCRIPTION PIC X(40).
EXEC SQL
FETCH C1 INTO DESCR
END-EXEC.
For more detail about the vary-length character string, refer to the SQL Programmer's Guide.
The above point is also true when using a high-level language to insert values into a variable length
field. The variable that contains the value to be inserted must be declared as variable or varying. A
PL/I example follows:
DCL FLD1 CHAR(40) VARYING;
FLD1 = XYZ Company;
EXEC SQL
INSERT INTO library/file VALUES
("001453", FLD1, ...);
Having defined FLD1 as VARYING will, for this example, insert a data string of 11 bytes into the
field corresponding with FLD1 in this file. If variable FLD1 had not been defined as VARYING, a
data string of 40 bytes would be inserted into the corresponding field. For additional information on
the VARYING attribute, refer to the PL/I User's Guide and Reference.
y
In summary, the proper implementation and use of DB2 variable length field support can help provide
overall improvements in both function and performance for certain types of database files. However,
the amount of improvement can be greatly impacted if the new support is not used correctly, so users
need to take care when implementing this function.
4.13 Reuse Deleted Record Space
Description of Function
This section discusses the support for reuse of deleted record space. This database support provides the
customer a way of placing newly-added records into previously deleted record spaces in physical files.
This function should reduce the requirement for periodic physical file reorganizations to reclaim deleted
record space. File reorganization can be a very time consuming process depending on the size of the file
and the number of indexes over it, along with the reorganize options selected. To activate the reuse
function, set the Reuse deleted records (REUSEDLT) parameter to *YES on the CRTPF (Create Physical
File) The default value when creating a file with CRTPF is *NO (do not reuse). The default for SQL
Create Table is *YES.
Comparison to Normal Inserts
Inserts into deleted record spaces are handled differently than normal inserts and have different
performance characteristics. For normal inserts into a physical file, the database support will find the end
of the file and seize it once for exclusive use for the subsequent adds. Added records will be written in
blocks at the end of the file. The size of the blocks written will be determined by the default block size or
by the size specified using an Override Database File (OVRDBF) command. The SEQ(*YES number of
records) parameter can be used to set the block size.
IBM i 6.1 Performance Capabilities Reference - January/April/October 2008
©
Copyright IBM Corp. 2008
Chapter 4 - DB2 Performance
61