Including Structured Query Language (SQL) Statements in Your ILE COBOL Program

The syntax for SQL statements embedded in an ILE COBOL source program is:

Imbedding SQL Statements

Read syntax diagramSkip visual syntax diagramEXEC SQLsql-statementEND-EXEC.

If the member type for the source program is SQLCBLLE when the COBOL syntax checker encounters an SQL statement, the statement is passed to the SQL syntax checker. If an error is detected, a message is returned.

If an SQL statement is encountered, and if the member type is not SQLCBLLE a message is returned indicating that an ILE COBOL statement is in error.

If there are errors in the embedded SQL statement as well as errors in the preceding ILE COBOL statements, the SQL error message will only be displayed after the preceding COBOL errors are corrected.

You can create SQL programs for use with your ILE COBOL programs. The SQL cursor used by your ILE COBOL program may be scoped to either the module object or the activation group. You specify the SQL cursor scoping through the CLOSQLCSR parameter of the Create SQL Program commands (CRTSQLxxx).

For more information about SQL statements and SQL cursors, 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/.