MC Press Online

Monday, Feb 27th

Last updateWed, 22 Feb 2017 3pm

You are here: Home ARTICLES Programming SQL TechTip: SQL and i5/OS Record Format Names

Programming / SQL

TechTip: SQL and i5/OS Record Format Names

Support MC Press - Visit Our Sponsors

NEW BOOK!

Flexible Input, Dazzling Output with IBM i


ORDER YOUR COPY

*******************

Click for this Month's

Bookstore Special Deals

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 This email address is being protected from spambots. You need JavaScript enabled to view it..

Kent Milligan

Kent Milligan is a Senior Technical Team Lead on the Emerging Technology Delivery team for the IBM Watson for Clinical Trial Matching solution. Prior to joining the Watson team in 2015, Kent spent the first 25 years of his career working as a DB2 for IBM i consultant and developer working out of the IBM Rochester lab.

 

Read Kent's "DB2 farewell" blog:

http://db2fori.blogspot.com/2015/06/time-for-new-challenge.html

BLOG COMMENTS POWERED BY DISQUS