SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Embedded SQL Statements
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
2-4
Nonexecutable SQL Statements
 }
}; // end of jobsql class definition
Nonexecutable SQL Statements
You can place a specific set of static SQL statements anywhere in an embedded C, 
C++, or COBOL program. However, these statements affect only the compilation of the 
static SQL statements that they precede. For a list of these static SQL declarations and 
statements, see Table 2-3 on page 2-7. 
Code these SQL declarations anywhere in your program but with the restrictions 
shown in these COBOL examples: 
•
DECLARE CATALOG declarations—before the SQL statements with the 
unqualified schema names to which the declaration applies: 
EXEC SQL DECLARE CATALOG 'samdbcat' END-EXEC.
EXEC SQL DELETE FROM persnl.employee ... END-EXEC. 
•
DECLARE SCHEMA declarations—before the SQL statements with the unqualified 
object names to which the declaration applies: 
EXEC SQL DECLARE SCHEMA 'samdbcat.persnl' END-EXEC.
EXEC SQL DELETE FROM employee ... END-EXEC. 
•
DECLARE CURSOR declarations—before the associated OPEN statement and 
processing statements using the cursor: 
 EXEC SQL DECLARE get_employee CURSOR FOR 
 SELECT empnum, jobcode, salary
 FROM employee 
 WHERE deptnum = :HV-DEPTNUM 
 END-EXEC.
* Move value into HV-DEPTNUM 
 ...
 EXEC SQL OPEN get_employee END-EXEC. 
•
WHENEVER declarations—before the SQL statements to which the declaration 
applies: 
EXEC SQL WHENEVER NOT FOUND 
 PERFORM 7000-ROW-NOT-FOUND
END-EXEC. 
...
EXEC SQL SELECT ... END-EXEC. 
Executable SQL Statements
In an embedded C, C++, or COBOL program, you must place executable SQL 
statements within the body of the program, such as in main() for C or C++ programs 
or within the body of other functions or procedures in the program. Code the listed 
types of executable SQL statements as you would executable 3GL statements:
•
SQL statements that process dynamic SQL










