TR7's enhanced SQL Field Reference information and Generate SQL support make it easier to increase your adoption of SQL.
If you've closely followed the enhancements being delivered for DB2 for i, you've noticed that each round of enhancements usually includes a couple features that make it easier for IBM i developers to adopt and use SQL. For example, recent DB2 for i updates made it easier to utilize SQL in CL programs with the RUNSQL command and to access SQL-created tables from RPG programs with the new RCDFMT keyword.
The recently announced Technology Refresh 7 for the IBM i 7.1 release follows this SQL modernization trend with DB2 enhancements that deliver field reference support for the CREATE TABLE AS statement as well as enhanced capabilities for the Generate SQL utility for converting existing DB2 objects from DDS to SQL.
The Generate SQL task has been available in IBM i Navigator for many releases, but it didn't fully address the keyed aspect of keyed logical files and physical files. With this new support, DB2 can generate not only CREATE VIEW and CREATE TABLE statements for these objects, but also CREATE INDEX statements to address the key field specifications in these DDS objects. The CREATE INDEX statement generation is accomplished by using the new output options that are highlighted at the end of the following Generate SQL dialog window.
Figure 1: Note the options at the bottom of the Output options list.
This Generate SQL support requires you to load the IBM i 7.1 Database Group PTF level 25 onto your server and to update your workstation with the IBM i Access for Windows service pack scheduled for availability in December 2013.
When moving over to the SQL world, a number of IBM i developers also want to continue to leverage their existing field reference files when creating DB2 objects. The DB2 for i SQL support has accommodated that need with the CREATE TABLE AS statement. The following SQL example creates a new DB2 table that uses the common field definitions stored in the field reference file named FLDREF.
CREATE TABLE mylib/new_table AS
(SELECT id AS CustID, acct6 AS CustRewardsNum,
name30 AS CustLastName FROM mylib/fldref)
WITH NO DATA
Developers don't have to manually duplicate the field attributes. The CREATE TABLE AS support retrieves the attributes for the ID, ACCT6, and NAME30 fields from the field reference file and utilizes those attributes in the definitions for the CustID, CustRewardsNum, and CustLastName columns.
While this SQL Field Reference File support works, it was deficient because there is no record of the fact that the SQL table definition has dependencies on field definitions from another file. This is reinforced by the Display File Field Definition (DSPFFD) output in Figure 2, which lacks reference information for the column definitions.
Figure 2: This DSPFFD output has no reference information.
This missing reference information made impact analysis quite difficult when determining how many tables and programs needed to change as a result of changing a field definition. IBM has eliminated this difficulty by enhancing the CREATE TABLE AS statement to propagate field dependency information into the table object being created. Figure 3 shows the DSPFFD output that's been enhanced with reference information by the latest DB2 for i update.
Figure 3: The new DSPFFD output shows reference information.
The added reference information makes it quite obvious that the new_table column definitions have a dependency on the field definitions stored in the MYLIB/FLDREF field reference file. The new field reference support is not limited to references of DDS-based field reference files. The CREATE TABLE AS statement will capture the reference information for any type of DB2 object that's referenced. In addition, the CREATE TABLE LIKE statement will also propagate the reference information into the new table.
This field reference information enhancement is available on both the IBM i 6.1 and 7.1 releases. This requires loading IBM i 6.1 Database Group PTF level 31 and IBM i 7.1 Database Group PTF level 25, respectively.
Hopefully, you are able to use these DB2 enhancements in Technology Refresh 7 to increase your adoption and usage of SQL.