Embedded SQL Statements and Fortran If Blocks
Because each Embedded SQL statement must be on a line by itself, you must use the block-style Fortran if statement to conditionally transfer control to Embedded SQL statements. For example:
if (error) then
exec sql message 'Error on update'
exec sql sleep 2
end if
Note that the esqlf preprocessor also generates many nested constructs of do loops and if blocks--specifically, for Embedded SQL block-structured statements, such as display and unloadtable. If you mistakenly omit an end if from your Fortran source, the Fortran compiler complains that there is a missing end statement, which you can trace back to a preprocessor-generated if or do (VMS or Windows).
You can usually solve this problem by checking for matching if-end pairs in the original Embedded SQL Fortran source file. In VMS or Windows, you can also check for do-end pairs as well.