Using directives in ILE RPG applications that use SQL
RPG directives are handled by the SQL precompiler according to the value of the RPG preprocessor options parameter (RPGPPOPT). If the RPG preprocessor is used, the SQL precompile will run using the expanded preprocessed source.
- When the value is *NONE, the RPG preprocessor
is not called to preprocess the RPG source. When a source stream file
is precompiled, no directives are recognized by SQL. When a source
member is precompiled, the only directive that is handled by the SQL
precompiler is /COPY. Nested /COPY statements are not handled.
In fully free-form source mode, /COPY statements that start in any column are handled by the SQL precompiler. In column-limited source mode, only /COPY statements that start in column 7 are handled by the SQL precompiler. All /COPY statements must reference a source member; they cannot reference a source stream file.
All other directives are ignored until the RPG compiler is called. This means that all RPG and SQL statements within conditional logic blocks are processed unconditionally by the SQL precompiler.
- When the value is *LVL1, the RPG preprocessor will be called to preprocess the RPG source. All /COPY statements are expanded, even nested /COPY statements, and the conditional compilation directives will be handled.
- When the value is *LVL2, the RPG preprocessor will be called to preprocess the RPG source. All /COPY and /INCLUDE statements are expanded and the conditional compilation directives will be handled.
- When *LVL1 or *LVL2 is used, there is a possibility that the expanded source generated by the RPG preprocessor will become very large and reach a resource limit due to the expansion of the /COPY and /INCLUDE statements. If this happens you must either break up your source into smaller pieces, or not use the RPG preprocessor.