Comments
You can include a comment field or line in an Embedded SQL statement by typing the exclamation point (!) at the beginning of the comment field. The following example shows the use of a comment field on the same line as an Embedded SQL statement:
exec sql open empcsr ! Process employees
The next example shows the use of a comment field embedded in an SQL statement:
exec sql select ename &
into :namevar &
from employee &
! Confirm that "eno" is the same as
! the current value chosen
where eno = :currentval
In both cases, the preprocessor ignores the comment field. Note that a comment field terminates with the newline. A comment field cannot be continued over multiple lines.
A comment line can appear anywhere in an Embedded SQL program that a blank line is allowed, with the following exceptions:
• In string constants. Such a comment would be interpreted as part of the string constant.
• In parts of statements that are dynamically defined. For example, a comment in a string variable specifying a form name is interpreted as part of the form name.
• Between component lines of Embedded SQL block-type statements. All block-type statements (such as activate and unloadtable) are compound statements that include a statement section delimited by begin and end. Comment lines must not appear between the statement and its section. The preprocessor would interpret such comments as BASIC host code, causing preprocessor syntax errors. (Note, however, that the comment begun by the exclamation point can appear on the same line as the statement.) For example, the following statement would cause a syntax error on the first comment:
exec frs unloadtable empform employee (:namevar = ename)
! Illegal comment before statement body.
exec frs begin
! Comment legal here
exec frs message :namevar ! And legal here too
exec frs end
• Statements that are made up of more than one compound statement, such as the display statement, which typically consists of the display clause, an initialize section, activate sections, and a finalize section, cannot have comments between any of the components. These comments would be translated as host code and would cause syntax errors on subsequent statement components.
A comment line can also begin with the BASIC rem keyword.
The SQL comment delimiter "--" acts just like the "!" delimiter; it indicates that the rest of the line is a comment.
Last modified date: 04/03/2024