SQL SECTION is part of the Embedded SQL standard (ISO/IEC 9075-2). It appears only inside EXEC SQL statements and is used to declare host variables that a host language (C, C++, COBOL, etc.) can pass to and from the database. The block is delimited by EXEC SQL BEGIN DECLARE SECTION; and EXEC SQL END DECLARE SECTION;. Everything between those two statements is treated by the pre-compiler as host-language code whose variables become usable in subsequent embedded SQL commands. The SECTION keyword itself does not execute at runtime; it guides the pre-compiler. Omitting it or mis-pairing BEGIN and END leads to compilation errors. SECTION is mandatory when you want to use host variables without explicitly prefixing each one with a host indicator (for example, :var in Pro*C).
EXEC SQL, Host Variables, PREPARE, DECLARE CURSOR, FETCH
SQL-92 Embedded SQL (ISO/IEC 9075-2:1992)
C, C++, COBOL, and other languages that have an Embedded SQL pre-compiler compatible with ISO/IEC 9075-2.
Most pre-compilers do not allow nesting. Use one BEGIN/END pair per compilation unit.
If your pre-compiler supports the :host_var syntax outside SECTION blocks, you can omit it, but using SECTION improves readability and portability.
No. It is a compile-time directive only; it has zero runtime cost.