The Structured Query Language

The DB2® UDB for iSeries database can be accessed from an ILE RPG program by embedding SQL statements into your program source. The syntax is shown in DB2 UDB for iSeries Syntax. Use the following rules to enter SQL statements:
  • Enter SQL statements on a calculation specification.
  • SQL statements can be fixed-form or free-form.
    • For free-form SQL statements, the first line of the statement begins with EXEC SQL. The remainder of the statement can be on any line, including the first line. The statement ends with a semicolon. See Free-Form Statements for information on the columns available for free-form statements.
    • For fixed-form SQL statements:
      • Start fixed-form SQL statements using the delimiter /EXEC SQL in positions 7-15, with the slash in position 7.
      • You can start entering SQL statements on the same line as the starting delimiter.
      • Use the continuation line delimiter (+ in position 7) to continue SQL statements on any subsequent lines.
      • Use the ending delimiter /END-EXEC in positions 7-15 (with the slash in column 7) to signal the end of the SQL statements. The ending delimiter goes on a separate line.
      • Fixed-form SQL statements cannot go past position 80.
You must enter a separate command to process the SQL statements.
Note: SQL statements cannot be specified in the referred source member of a /COPY statement.

Refer to the IBM® i Information Center database and file systems category for the descriptions of how to code SQL statements.