SQL statements coded in an RPG/400® program must be placed in the calculation section.
This requires that a C be placed in position 6. SQL statements can be placed in detail calculations, in total calculations, or in an RPG/400 subroutine. The SQL statements are run based on the logic of the RPG/400 statements.
The keywords EXEC SQL indicate the beginning of an SQL statement. EXEC SQL must occupy positions 8 through 16 of the source statement, preceded by a / in position 7. The SQL statement may start in position 17 and continue through position 74.
The keyword END-EXEC ends the SQL statement. END-EXEC must occupy positions 8 through 16 of the source statement, preceded by a slash (/) in position 7. Positions 17 through 74 must be blank.
Both uppercase and lowercase letters are acceptable in SQL statements.