Figure 1 and Figure 2 show examples of embedded SQL statements.
...+....1....+....2....+....3....+....4....+....5....+....6....+....7..
/FREE
X = Y + Z; // ILE RPG calculation operations
// The entire SQL statement is on one line
EXEC SQL INSERT INTO MYLIB/MYFILE (FLD1) VALUES(12);
// The SQL statement begins on the same line as
// EXEC SQL and then it is is split across several lines
EXEC SQL INSERT
INTO MYLIB/MYFILE
(FLD1) VALUE(12);
// The SQL statement begins on the line after
// EXEC SQL and then it is is split across several lines
EXEC SQL
INSERT INTO MYLIB/MYFILE
(FLD1) VALUE(12);
X = Y + Z; // ILE RPG calculation operations
/END-FREE
...+....1....+....2....+....3....+....4....+....5....+....6....+....7..
* ILE RPG calculation operations
C EVAL X = Y + Z
* The entire SQL statement is on one line
C/EXEC SQL INSERT INTO MYLIB/MYFILE (FLD1) VALUES(12)
C/END-EXEC
* The SQL statement begins on the same line as
* EXEC SQL and then it is is split across several lines
C/EXEC SQL INSERT
C+ INTO MYLIB/MYFILE
C+ (FLD1) VALUE(12)
C/END-EXEC
* The SQL statement begins on the line after
* EXEC SQL and then it is is split across several lines
C/EXEC SQL
C+ INSERT INTO MYLIB/MYFILE
C+ (FLD1) VALUE(12)
C/END-EXEC
* ILE RPG calculation operations
C EVAL X = Y + Z
C
You must enter a separate command to process the SQL
statements. For more information, refer to the DB2 for
i section of the Database
and File Systems category in the IBM® i
Information Center at this
Web site - http://www.ibm.com/systems/i/infocenter/.
Refer to the ADTS for AS/400®: Source Entry Utility manual for information about how SEU handles SQL statement syntax checking.