Application programming statements and embedded SQL statements are the primary input to the SQL precompiler.
In PL/I, C, and C++ programs, the SQL statements must use the margins that are specified in the MARGINS parameter of the CRTSQLPLI, CRTSQLCI, and CRTSQLCPPI commands.
The SQL precompiler assumes that the host language statements are syntactically correct. If the host language statements are not syntactically correct, the precompiler may not correctly identify SQL statements and host variable declarations. There are limits on the forms of source statements that can be passed through the precompiler. Literals and comments that are not accepted by the application language compiler, can interfere with the precompiler source scanning process and cause errors.
You can use the SQL INCLUDE statement to get secondary input from the file that is specified by the INCFILE parameter of the CRTSQLxxx. The xxx in this command refers to the host language indicators: CBL for the COBOL for iSeries™ language, CBLI for the ILE COBOL for iSeries language, PLI for the iSeries PL/I language, CI for the ILE C for iSeries language, RPG for the RPG/400® language, RPGI for the ILE RPG language, CPPI for the ILE C++/400 language. The SQL INCLUDE statement causes input to be read from the specified member until it reaches the end of the member. The included member may not contain other precompiler INCLUDE statements, but can contain both application program and SQL statements.
If mixed DBCS constants are specified in the application program source, the source file must be a mixed CCSID.
You can specify many of the precompiler options in the input source member by using the SQL SET OPTION statement.
The RPG preprocessor options (RPGPPORT) parameter of the CRTSQLRPGI command has two options to call the RPG preprocessor. If *LVL1 or *LVL2 is specified, the RPG compiler will be called to preprocess the source member before the SQL precompile is run. Preprocessing the SQL source member will allow many compiler directives to be handled before the SQL precompile. The preprocessed source will be placed in file QSQLPRE in QTEMP. This source will be used as the input for the SQL precompile. The CCSID used by the SQL precompile is the CCSID of QSQLPRE.