![]() |
|
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 selected 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 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.
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.
In DB-Access, 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 how to create and modify command files with the SQL editor or a system editor in DB-Access, see the DB-Access User's Manual.
You can use either comment symbol in any line of an SPL routine. See the discussion of how to comment and document an SPL routine in the Informix Guide to SQL: Tutorial.
In ESQL/C, you can use the double dash (--) to comment SQL statements. For further information on the use of SQL comment symbols and language-specific comment symbols in ESQL/C programs, see the Informix ESQL/C Programmer's Manual.
Some simple examples can help to illustrate the different ways to use the SQL comment symbols.
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:
The following example shows the use of braces ({}) 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:
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 Informix Guide to GLS Functionality.