Coding SQL statements
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.
About this task
You also need to do these special steps:
- Code an
EXEC SQL INCLUDEstatement to include an SQL communication area (SQLCA) in theWORKING-STORAGE SECTIONorLOCAL-STORAGE SECTIONof the outermost program.LOCAL-STORAGEis recommended for recursive programs and programs that use theTHREADcompiler option. - Define all host variables that you use in
SQL statements in the
WORKING-STORAGE SECTION,LOCAL-STORAGE SECTION, orLINKAGE SECTION. However, you do not need to identify them withEXEC SQL BEGIN DECLARE SECTIONandEXEC SQL END DECLARE SECTION.
Restriction: You cannot use SQL
statements in object-oriented classes or methods.
Related tasks
Using SQL INCLUDE with the Db2 coprocessor
Using character data in SQL statements
Using national decimal data in SQL statements
Using national group items in SQL statements
Using binary items in SQL statements
Determining the success of SQL statements
DB2® Application Programming and SQL Guide (Coding SQL statements in a
COBOL application)
Using SQL INCLUDE with the Db2 coprocessor
Using character data in SQL statements
Using national decimal data in SQL statements
Using national group items in SQL statements
Using binary items in SQL statements
Determining the success of SQL statements
DB2® Application Programming and SQL Guide (Coding SQL statements in a
COBOL application)
Related references
Code-page determination for string host variables in SQL statements
DB2 SQL Reference
Code-page determination for string host variables in SQL statements
DB2 SQL Reference