TechTip: V5R3 PTFs for SQL and RPG Free-Format

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

In recent years, many RPG programmers have improved their productivity by using the free-format syntax. V5R4 expanded this functionality for RPG programmers who utilize SQL by allowing SQL requests to be embedded into free-format RPG for the first time. Prior to this enhancement, developers had to move in and out of the free-format syntax whenever they wanted to code SQL.

To make this valuable enhancement available to a wider community of System i developers, IBM has recently made this support available on V5R3 with the following PTFs:

  • SI25763 5722-ST1
  • SI25532 5722-SS1
  • SI23384 5722-SS1

These V5R3 PTFs can also be obtained by applying V5R3 Database Group PTF #16 (or later) to your system.

This example proves that this cumbersome requirement has been removed:

d getOrderCount   pi            10i 0
d  inCustNumber                  9b 0 const
d  outSqlState                   5a
d  outSqlMsg                   256a
d  ordercount     s             10i 0
 /free
   outSqlMsg   = *blanks;

   exec sql SELECT count(*) into :orderCount
            FROM allOrders
            WHERE customer_no = :inCustNumber;

  outSqlState = sqlState;
  if %subst(sqlState:1:2) <> '00';
   exec sql GET DIAGNOSTICS CONDITION 1
                 :outSqlMsg = MESSAGE_TEXT;
    orderCount = 0;
  endif;

  return orderCount;
 /end-free

It should be noted that, by using the TGTRLS parameter, programs using SQL, RPG, and free-form together can be compiled to go all the way back to V5R1. This as true as long as you do your application development on V5R3 with these PTFs installed and you're using SQL syntax that is supported on the older releases. Similarly, the TGTRLS parameter can be used on a V5R4 system to create program objects for systems that go all the way back to V5R2. This great flexibility allows you to use this new free-format SQL support while still supporting older releases.

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: