Previous Topic: COBOLNext Topic: Assembler


PL/I and C

All embedded SQL statements in PL/I and C programs are preceded by the keywords EXEC SQL and followed by a semicolon:

 EXEC SQL
     statement
 ;

The identifying words EXEC SQL (which are reserved), the statement, and the terminating semicolon can appear on one or more lines within the prescribed margins. Do not include code unrelated to SQL on these lines since the Preprocessor comments them. The word EXEC must be separated from the word SQL, and the word SQL must be separated from the statement. The semicolon can directly follow the last letter of the statement.

Example 1

 EXEC SQL
     DECLARE ADDR_CURSOR CURSOR FOR
     SELECT ID, NAME_LAST, STATE FROM ADDRTBL;

Example 2

 EXEC SQL
     WHENEVER NOT FOUND GOTO ALL_DONE ;

Example 3

  EXEC SQL
     FETCH ADDR_CURSOR
         INTO :HID, :HNAME_LAST, :HSTATE;

Example 4

 EXEC SQL CLOSE ADDR_CURSOR;