Oracle PL/SQL - PL SQL Introduction Multiline Comments

Introduction

A multiline comment begins with /*, ends with */, and can span multiple lines.

The following code has two multiline comments.

Demo

SQL>
SQL> DECLARE-- from w  w  w.  ja v a  2  s  .c o  m
  2    some_condition  BOOLEAN;
  3    pi              NUMBER := 3.1415926;
  4    radius          NUMBER := 15;
  5    area            NUMBER;
  6  BEGIN
  7    /* Perform some simple tests and assignments */
  8
  9    IF 2 + 2 = 4 THEN
 10      some_condition := TRUE;
 11      DBMS_OUTPUT.PUT_LINE('I am in IF condition');
 12      /* true value*/
 13    END IF;
 14
 15    /* This line computes the area of a circle using pi. */
 16
 17    area := pi * radius**2;
 18    DBMS_OUTPUT.PUT_LINE('The area is: ' || TO_CHAR(area));
 19  END;
 20  /
I am in IF condition
The area is: 706.858335

PL/SQL procedure successfully completed.

SQL>

You can use multiline comment delimiters to "comment out" sections of code.

When doing so, be careful not to cause nested multiline comments: one multiline comment cannot contain another multiline comment.

A multiline comment can contain a single-line comment.

For example, this causes a syntax error:

/* 
  statements;
  statements;
  /* test */ 
  END IF; 
*/ 

This does not cause a syntax error:

/* 
  IF 2 + 2 = 4 THEN 
    some_condition := TRUE; 
  -- test
  END IF; 
*/ 

Related Topics