- You can begin the SQL statement string on the same line as the keyword
pair or a separate line. The statement string can be several lines
long. Do not split the EXEC SQL keyword pair between lines.
- You must use the SQL statement terminator. If you do not use it,
the precompiler will continue to the next terminator in the
application. This may cause indeterminate errors.
C/C++ comments can be placed before the statement initializer or
after the statement terminator.
- Multiple SQL statements and C/C++ statements may be placed on
the same line. For example:
EXEC SQL OPEN c1; if (SQLCODE >= 0) EXEC SQL FETCH c1 INTO :hv;
- The SQL precompiler leaves CR/LFs and TABs in a quoted string as
is.
- SQL comments are allowed on any line that is part of an embedded SQL
statement. These comments are not allowed in dynamically executed
statements. The format for an SQL comment is a double dash
(--) followed by a string of zero or more characters and terminated
by a line end. Do not place SQL comments after the SQL statement
terminator as they will cause compilation errors because they would appear to
be part of the C/C++ language.
You can use comments in a static statement string wherever blanks are
allowed. Use the C/C++ comment delimiters /* */,
or the SQL comment symbol (--). //-style
C++ comments are not permitted within static SQL statements, but
they may be used elsewhere in your program. The precompiler removes
comments before processing the SQL statement. You cannot use
the C and C++ comment delimiters /* */ or //
in a dynamic SQL statement. However, you can use them elsewhere in your
program.
- You can continue SQL string literals and delimited identifiers over line
breaks in C and C++ applications. To do this, use a back
slash (\) at the end of the line where the break is desired. For
example:
EXEC SQL SELECT "NA\
ME" INTO :n FROM staff WHERE name='Sa\
nders';
Any new line characters (such as carriage return and line feed) are not
included in the string or delimited identifier.
- Substitution of white space characters such as end-of-line and TAB
characters occur as follows:
- When they occur outside quotation marks (but inside SQL statements),
end-of-lines and TABs are substituted by a single space.
- When they occur inside quotation marks, the end-of-line characters
disappear, provided the string is continued properly for a C program.
TABs are not modified.
Note that the actual characters used for end-of-line and TAB vary from
platform to platform. For example, OS/2 uses Carriage Return/Line Feed
for end-of-line, whereas UNIX-based systems use just a Line Feed.