OpenSQL Reference Guide > OpenSQL Reference Guide > Embedded OpenSQL > Syntax of an Embedded OpenSQL Statement
Was this helpful?
Syntax of an Embedded OpenSQL Statement
The syntax of an embedded OpenSQL statement is as follows:
[margin] EXEC SQL OpenSQL_statement [terminator]
When writing embedded OpenSQL statements, keep the following points in mind:
The margin, consisting of spaces or tabs, is the margin that the host language compiler requires before the regular host code. Not all languages require margins. To determine if a margin is required, see the Embedded SQL Companion Guide.
The keywords EXEC SQL must precede the OpenSQL statement; otherwise the statement is ignored. These words must appear together on a single line. They signal the preprocessor that the statement is an embedded OpenSQL statement.
The statement terminator depends on the requirements of the host language. Different host languages require different terminators. Some host languages, such as Fortran, do not require a statement terminator.
Embedded OpenSQL statements can be continued across multiple lines, according to the host language's rules for line continuation.
Labels can precede the embedded statement if a host language statement in the same place can be preceded by a label. The label must be at the correct margin for labels and no syntactic element (including comments) can appear between it and the EXEC keyword.
Host language comments must follow the rules for the host language.
Some host languages allow you to place a line number in the margin.
For information about language‑dependent syntax, see the Embedded SQL Companion Guide.
Last modified date: 11/09/2022