The DB2 UDB for iSeries® database can be accessed from an ILE RPG program by embedding SQL statements into your program source. Use the following rules to enter your SQL statements:
Figure 30 and Figure 31 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 Universal Database for iSeries section of the Database and File Systems category in the i5/OS 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.
See Using the application development tools in the client product for information about getting started with the client tools.