Delimit SQL statements with EXEC SQL and
END-EXEC.
The EXEC SQL and END-EXEC
delimiters must each be complete on one line.
You cannot continue them across multiple lines.
Do not code COBOL statements within EXEC SQL statements.
You also need to do these special steps:
-
Code an EXEC SQL INCLUDE statement
to include an SQL
communication area (SQLCA) in the WORKING-STORAGE SECTION or
LOCAL-STORAGE SECTION of the outermost program.
LOCAL-STORAGE is recommended for recursive programs and
programs that use the THREAD compiler option.
- Declare all host variables that you use in SQL statements in
the WORKING-STORAGE SECTION, LOCAL-STORAGE SECTION,
or LINKAGE SECTION.
However, you do not need to identify them
with EXEC SQL BEGIN DECLARE SECTION and
EXEC SQL END DECLARE SECTION.
Restriction:
You cannot use SQL statements in
object-oriented classes or methods.
You can use SQL statements even for large
objects (such as BLOB and CLOB) and compound SQL.