TechTip: SQL and i5/OS Record Format Names

SQL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 Db2 for i Consultant in the IBM Lab Services Power Systems Delivery Practice.  Kent has over 25 years of experience as a Db2 for IBM i consultant and developer working out of the IBM Rochester lab. Prior to re-joining the DB2 for i Lab Services practice in 2020, Kent spent 5 years working on healthcare solutions powered by IBM Watson technologies. Kent is a sought-after speaker and author on Db2 for i & SQL topics.
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: