When using SQL to create DB2 for i5/OS tables that will be accessed by non-SQL interfaces, such as RPG native interfaces, you need to consider the record format name generated by DB2. By default, the record format name for an SQL created table is identical to the table (or file) name. As you know, having the record format name be the same as the file name is problematic when you need to access that table with the native record-level accesses in RPG.
Prior to V5R4, the SQL RENAME TABLE statement could be used in conjunction with the SQL CREATE TABLE statement to allow you to control the record format name used by DB2 for SQL-created objects. Here were the steps involved:
1. The table is created using the record format name, CMFMT, as the table name because, by default, DB2 uses the same value for the table name and record format name.
CREATE TABLE dbtest/cmfmt
(cusname CHAR(20),
cuscity CHAR(40))
2. The Rename Table statement is used on the newly created table to change the table name to a value different from the record format name. The Rename Table statement does not change the record format name.
RENAME TABLE dbtest/cmfmt TO cusmst
After these steps, the SQL-created table has a table name (CUSMST) that is different from the record format name (CMFMT).
With V5R4, DB2 for i5/OS greatly simplified this process by supporting a new RCDFMT keyword on the Create Table statement. The following example shows how this new keyword makes it much simpler to create an SQL table in which the record format name is different from the table name.
CREATE TABLE dbtest/cusmst
(cusname CHAR(20),
cuscity CHAR(40)) RCDFMT cmfmt
It should be noted that this new RCDFMT keyword was not documented in the SQL Reference guide that was made available at the GA of V5R4. IBM has recently updated the V5R4 SQL Reference. Thus, if you downloaded a PDF version of the SQL Reference when the V5R4 documentation was first made available, you should visit the iSeries Information Center and download the latest version of the DB2 for i5/OS SQL Reference.
Kent Milligan is a DB2 Technology Specialist on IBM's ISV Enablement team for System i. He spent the first seven years at IBM as a member of the DB2 development team in Rochester. He can be reached at
TechTip: SQL and i5/OS Record Format Names
Typography
- Smaller Small Medium Big Bigger
- Default Helvetica Segoe Georgia Times
- Reading Mode
LATEST COMMENTS
MC Press Online