Question & Answer
Question
Answer
However, the SQL precompiler does not know how to process compiler directives such as /COPY, /INCLUDE, /DEFINE, and /IF. This can cause your compile to fail in a variety of ways depending on the specifics of your program, commonly with:
RNF7030 The name or indicator is not defined
and/or
RNF7503 Expression contains an operand that is not defined.
To resolve this, you need to specify RPGPPOPT(*LVL2) on your CRTSQLRPGI command. This will cause the ILE RPG compiler to process the compiler directives before passing control to the SQL precompiler. Since the conditional directives have already been processed, all the variables needed by your SQL statements will be defined.
The shipped value is currently RPGPPOPT(*NONE). There are no drawbacks to specifying RPGPPOPT(*LVL2), so you could consider changing your command default to use RPGPPOPT(*LVL2). If you use change management software, you may be able to set a default there.
Here is how you could change the default:
CHGCMDDFT CMD(QSQL/CRTSQLRPGI) NEWDFT('RPGPPOPT(*LVL2)')
Keep in mind, when you change the default for an IBM command, if the command is PTFd, the new command will revert back to the shipped default which is currently RPGPPOPT(*NONE), so you would have to change it again. The same is true when you upgrade to a new release.
This topic is covered in Embedding SQL statements in ILE RPG applications that use SQL in Knowledge Center:-Was this topic helpful?
Document Information
Modified date:
09 December 2024
UID
nas8N1021769