| V6R1 SQL ILE RPG Precompiler Enhancements |
|
|
|
| Programming - RPG | |||
| Written by Gina Whitney | |||
| Tuesday, 01 April 2008 19:00 | |||
|
Variable scoping support, the ability to take a source stream file as input, increased LOB limits, and so much more!
If you have been using the SQL ILE RPG precompiler for many releases, you probably know that it does not fully support all the features that the compiler offers. In V5R3, enhancements were made to the precompiler to support commonly used compiler features. These enhancements were the beginning of a precompiler revolution. The gap between the precompiler and the compiler is narrowing, embedding SQL into programs is becoming more seamless, and attitudes about the precompiler are changing.
The precompiler revolution continues in V6R1, with the biggest release ever for the SQL ILE RPG precompiler. Not only did the precompiler catch up on some missing function, it also added support for the new compiler enhancements. The precompiler added variable scoping support, the ability to take a source stream file as input, the ability to do a LIKE on the SQLCA variables, increased LOB limits, and several new file enhancements. Now let's take a closer look at each enhancement. Variable ScopingThis is something that a new user of the precompiler would have assumed is supported. Veterans know that this is not the case, since you probably have gotten an error or two and spent some time trying to figure out what is wrong with the variable. I'm happy to say that variables are finally scoped to procedures and work as you would expect. Now you don't have to remember to use unique names or remember what the rules are for the precompiler to accept the duplicated name if the names are not unique. The great news about this is that you can precompile to a previous release, and it will still allow the duplicated names. The precompiler however still does write its internally used generated variables globally.
As you know, there were lots of changes with how the precompiler handles variables in past releases. Here is an example of code that precompiled cleanly in V5R2, failed in V5R3 because of the stricter rules for duplicate names, and now precompiles cleanly in V6R1.
In the following source, ResultSet is defined twice, but with a different subfield definition in each of the procedures.
HNoMain DSubProc1 Pr DSubProc2 Pr PSubProc1 B D PI D Count S 5I 0 Inz(1) D ResultSet ds occurs(1) Inz D Fld1 10A c/exec SQL c+ Set Result Sets WITH RETURN TO CLIENT c+ Array :ResultSet for :Count rows c/end-exec P E PSubProc2 B D PI D Count S 5I 0 Inz(1) D ResultSet ds occurs(1) D Fld2 7A c/exec SQL c+ Set Result Sets WITH RETURN TO CLIENT c+ Array :ResultSet for :Count rows c/end-exec C Return P E
On V5R2, the precompiler defined the variables this way:
Data Names Define Reference COUNT 16 SMALL INTEGER PRECISION(4,0) FLD1 8 CHARACTER(10) FLD2 18 CHARACTER(7) IN RESULTSET RESULTSET 17 ARRAY(1) STRUCTURE
For the SQL statement in SubProc1, the precompiler was using an array that had a subfield of character length 7.
On V5R3, the precompiler defined the variables like this:
Data Names Define Reference COUNT 6 SMALL INTEGER PRECISION(4,0) 9 19 FLD1 8 CHARACTER(10) IN RESULTSET FLD2 18 CHARACTER(7) IN RESULTSET RESULTSET 7 ARRAY(1) STRUCTURE RESULTSET 17 ARRAY(1) STRUCTURE
SQL0314 35 11 Position 32 Host variable RESULTSET not unique. SQL5011 30 11 Position 32 Host structure array RESULTSET not defined or not usable. SQL0314 35 21 Position 32 Host variable RESULTSET not unique. SQL5011 30 21 Position 32 Host structure array RESULTSET not defined or not usable.
On V6R1, the precompiler defines the variables like so:
Data Names Define Reference COUNT 6 SMALL INTEGER PRECISION(4,0) IN RPG PROCEDURE SUBPROC1 9 COUNT 16 SMALL INTEGER PRECISION(4,0) IN RPG PROCEDURE SUBPROC2 19 FLD1 8 CHARACTER(10) IN RESULTSET IN RPG PROCEDURE SUBPROC1 FLD2 18 CHARACTER(7) IN RESULTSET IN RPG PROCEDURE SUBPROC2 RESULTSET 7 ARRAY(1) STRUCTURE IN RPG PROCEDURE SUBPROC1 RESULTSET 17 ARRAY(1) STRUCTURE IN RPG PROCEDURE SUBPROC2 SUBPROC1 4 RPG PROCEDURE SUBPROC2 14 RPG PROCEDURE
The correct definition of RESULTSET is used in each procedure. IFSThe precompiler is now able to take a source stream file as input. The source stream file (SRCSTMF) and SQL include directory (INCDIR) parameters were added to all the ILE precompilers. The SRCSTMF parameter takes the absolute or relative path name for the source. The precompiler will handle a path of up to 5000 characters. The parameter INCDIR is used only for SQL include statements. This is the IFS version of the include file (INCFILE) parameter. If you want an INCDIR parameter to be used on the compiler command, the compiler options (COMPILEOPT) parameter needs to be used. If the SQL INCLUDE statement has an absolute path, the precompiler will ignore the INCDIR value. If a relative path is specified, the precompiler searches for an include file in the directories in this order: the current directory, the path on the INCDIR parameter, and finally the directory where the input source is | |||
|
|||
| Last Updated on Thursday, 20 March 2008 11:31 |




