INFORMIX
Informix Guide to SQL: Syntax
Chapter 1: SQL Statements
Home Contents Index Master Index New Book

How to Enter SQL Comments

You can add comments to clarify the purpose or effect of particular SQL statements. Your comments can help you or others to understand the role of the statement within a program, stored procedure, or command file. The code examples in this manual sometimes include comments that clarify the role of an SQL statement within the code.

The following table shows the SQL comment symbols that you can enter in your code. A Y in a column signifies that you can use the symbol with the product or database type named in the column heading. An N in a column signifies that you cannot use the symbol with the product or database type that the column heading names.

Comment Symbol

SQL
APIs

Stored Procedures
(SPL)
DB-Access


ANSI-Compliant Databases
Databases
That Are
Not ANSI Compliant
Description


double dash
(--)

Y

Y

Y

Y

Y

The double dash precedes the comment. The double dash can comment only a single line. To comment more than one line, you must put the double dash at the beginning of each comment line.

curly brackets
({})

N

Y

Y

Y

Y

Curly brackets enclose the comment. The { precedes the comment, and the } follows the comment. You can use curly brackets for single-line comments or for multiple-line comments.

If the product that you are using supports both comment symbols, your choice of a comment symbol depends on your requirements for ANSI compliance:

If ANSI compliance is not an issue, your choice of comment symbols is a matter of personal preference.

DB
You can use either comment symbol when you enter SQL statements with the SQL editor and when you create SQL command files with the SQL editor or 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 Informix Guide to SQL: Tutorial. For information on creating and modifying command files with the SQL editor or a system editor in DB-Access, see the DB-Access User Manual.

SPL
You can use either comment symbol in any line of a SPL routine. See the discussion of commenting and documenting a procedure in the Informix Guide to SQL: Tutorial.

ESQL
You can use the double dash (--) to comment SQL statements in your SQL API. For further information on the use of SQL comment symbols and language-specific comment symbols in application programs, see the manual for your SQL API.

Examples of SQL Comment Symbols

Some simple examples can help to illustrate the different ways of using the SQL comment symbols.

Examples of the Double-Dash Symbol

The following example shows the use of the double dash (--) to comment an SQL statement. In this example, the comment appears on the same line as the statement.

In the following example, the user enters the same SQL statement and the same comment as in the preceding example, but the user places the comment on a line by itself:

In the following example, the user enters the same SQL statement as in the preceding example but now enters a multiple-line comment:

Examples of the Curly-Brackets Symbols

The following example shows the use of curly brackets ({}) to comment an SQL statement. In this example, the comment appears on the same line as the statement.

In the following example, the user enters the same SQL statement and the same comment as in the preceding example but places the comment on a line by itself:

In the following example, the user enters the same SQL statement as in the preceding example but enters a multiple-line comment:

Non-ASCII Characters in SQL Comments

GLS
You can enter non-ASCII characters (including multibyte characters) in SQL comments if your locale supports a code set with the non-ASCII characters. For further information on the GLS aspects of SQL comments, see the Guide to GLS Functionality.




Informix Guide to SQL: Syntax, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.