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 inCustNumber 9b 0 const
d outSqlState 5a
d outSqlMsg 256a
d ordercount s 10i 0
outSqlMsg = *blanks;
exec sql SELECT count(*) into :orderCount
WHERE customer_no = :inCustNumber;
outSqlState = sqlState;
if %subst(sqlState:1:2) <> '00';
exec sql GET DIAGNOSTICS CONDITION 1
:outSqlMsg = MESSAGE_TEXT;
orderCount = 0;
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.