How to Enter SQL Comments
You can add comments to clarify the purpose or effect of particular SQL statements. You can also use comment symbols during program development to disable individual statements without deleting them from your source code.
Your comments can help you or others to understand the role of the statement within a program, SPL routine, or command file. The code examples in this document sometimes include comments that clarify the role of an SQL statement within the code, but your own SQL programs will be easier to read and to maintain if you document them with frequent comments.
The following table shows the SQL comment indicators that you can enter in your code. Here a Y in a column signifies that you can use the symbol with the product or with the type of database identified in the column heading. An N in a column signifies that you cannot use the symbol with the indicated product or with a database of the indicated ANSI-compliance status.
Comment Symbol | ESQL/C | SPL Routine | DB-Access | ANSI-Compliant Databases | Databases Not ANSI Compliant | Description |
---|---|---|---|---|---|---|
double hyphen (--) | Y | Y | Y | Y | Y | The double hyphen precedes a comment within a single line. To comment more than one line, put double hyphen symbols at the beginning of each comment line. |
braces ( { . . . } ) | N | Y | Y | Y | Y | Braces enclose the comment. The { precedes the comment, and the } follows it. Braces can delimit single- or multiple-line comments, but comments cannot be nested. |
slash and asterisk /* . . . */ | Y | Y | Y | Y | Y | C-language style slash and asterisk ( /* */ ) paired delimiters enclose the comment. The /* precedes the comment, and the */ follows it. These can delimit single-line or multiple-line comments, but comments cannot be nested. |
Characters within the comment are ignored by the database server.
The section Optimizer Directives describes a context where information within comments can influence query plans of HCL OneDB™.
- Double hyphen (
--
) complies with the ANSI/ISO standard for SQL. - Braces ( { } ) are the HCL OneDB extension to the ANSI/ISO standard.
- C-style slash-and-asterisk ( /* . . . */ ) comply with the SQL-99 standard.
If ANSI/ISO compliance is not an issue, your choice of comment symbols is a matter of personal preference.
In DB-Access, you can use any of these comment symbols when you enter SQL statements with the SQL editor and when you create SQL command files with the SQL editor or with a system editor.
An SQL command file is an operating-system file that contains one or more SQL statements. Command files are also known as command scripts. For more information about command files, see the discussion of command scripts in the HCL OneDB Guide to SQL: Tutorial. For information on how to create and modify command files with the SQL editor or a system editor in DB-Access, see the HCL OneDB DB-Access User's Guide.
You can use any of these comment symbols in any line of an SPL routine. See the discussion of how to comment and document an SPL routine in the HCL OneDB Guide to SQL: Tutorial.
In ,
the double hyphen ( --
) can begin a comment that
extends to the end of the same line. For information on language-specific
comment symbols in programs,
see the HCL OneDB
ESQL/C Programmer's Manual.