PL/SQL User's Guide and Reference

Contents Index Home Previous Next

Comments

Description

Comments describe the purpose and use of code segments and so promote readability. PL/SQL supports two comment styles: single-line and multi-line. Single-line comments begin with a double hyphen (- -) anywhere on a line and extend to the end of the line. Multi-line comments begin with a slash-asterisk (/*), end with an asterisk-slash (*/), and can span multiple lines. For more information, see "Comments" [*].

Syntax

comment ::=

{-- text | /* text */}

Usage Notes

Comments can appear within a statement at the end of a line. However, you cannot nest comments.

You cannot use single-line comments in a PL/SQL block that will be processed dynamically by an Oracle Precompiler program because end-of-line characters are ignored. As a result, single-line comments extend to the end of the block, not just to the end of a line. Instead, use multi-line comments.

While testing or debugging a program, you might want to disable a line of code. The following example shows how you can "comment-out" the line:

-- UPDATE dept SET loc = my_loc WHERE deptno = my_deptno;

You can use multi-line comment delimiters to comment-out whole sections of code.

Examples

The following examples show various comment styles:

-- compute the area of a circle
area := pi * radius**2;  -- pi equals 3.14159

/* Compute the area of a circle. */
area := pi * radius**2;  /* pi equals 3.14159 */

/*
  The following line computes the area of a circle using pi, 
  which is the ratio between the circumference and diameter. 
  Pi is an irrational number, meaning that it cannot be 
  expressed as the ratio between two integers.
*/
area := pi * radius**2;


Contents Index Home Previous Next