The following rules apply to Embedded SQL statements:
Embedded SQL statements begin with these keywords:
exec sql
Embedded SQL requires continuation characters in column 7 and tokens from column 8 to column 72. Place exec sql at the beginning of the statement.
The exec sql begin declare section statement must be aligned at the correct column for data declarations for the generated declaration section to be properly aligned, and to avoid compiler warnings.
If the source is in VMS TERMINAL format, Embedded SQL does not require that exec sql begin in any particular column.
Embedded SQL keywords are not case sensitive. exec sql, EXEC SQL, Exec Sql, or any other of case mix is equally valid. This manual consistently shows Embedded SQL keywords in lowercase. For example:
exec sql commit work end-exec.
All Embedded SQL statements end with the keyword end-exec. Place a period after end-exec when your program’s syntax or logic requires it. For example, the following code requires a period after end-exec because a COBOL paragraph must end with a period:
PARA-1.
IF SQLCODE = 0
exec sql commit work end-exec.
PARA-2.
In the next example, there is no period after the first end-exec because COBOL does not allow periods between if and else.
IF SQLCODE NOT = 0
exec sql rollback transaction disconnect
end-exec
ELSE
exec sql commit work end-exec.
Embedded SQL statements can extend across several lines. end-exec must be at the end of the statement’s last line or on a new line following the last line of code.