PL/SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PL/SQL Comment

PL/SQL Comment

shape Description

The PL/SQL compiler ignores the PLSQL Comment. The comments are nothing but the text in PL/SQL program. Comments are used to record the code. PLSQL Comment can be composed into two types

Single line comments

shape Description

Single line comments starts with two dashes - -. It can start anywhere on the line and ends anywhere on the line.

shape Syntax

SQL> - - Single Line comment;

shape Examples

The following example describes the single line comment in PL/SQL program. [c] sql>DECLARE 2 how many NUMBER; 3 num_tables NUMBER; 4 BEGIN 5 --Begin processing 6 SELECT COUNT(*) INTO how many 7 FROM USER_OBJECTS 8 WHERE OBJECT_TYPE='TABLE'; --Check number of tables 9 num_tables :=how many; --Compute some other values 10 END; 11 / PL/SQL program is successfully executed. [/c] The above example describes the PL/SQL standard program for composing single line comments.

Multiple line comments

shape Description

The multiple line comments starts with /* and ends with */ a symbol and can be applied to multiple lines. One can utilize multiple comments to comment-out different blocks of code.

shape Syntax

SQL> /* Multiple Comment line1 Multiple Comment line2 */

shape Examples

The below example describes multiple line comments in PL/SQL  program. [c]SQL> DECLARE 2 some_condition BOOLEAN; 3 pi NUMBER:=3.1415936; 4 radius NUMBER:=15; 5 area NUMBER; 6 BEGIN 7 /*Perform some simple tests and assignments*/ 8 IF 2+2=4 THEN 9 some_condition:=TRUE; 10 /* We expect this THEN to always be performed*/ 11 END IF; 12 /* The following line computes the area of a circle using pi, 13 which is the ratio between the circumstance and diameter. 14 After the area is computed,the result is displayed.*/ 15 area:=pi*radius**2; 16 DBMS_OUTPUT.PUT_LINE('The area is:'||TO_CHAR(area)); 17 END; 18 / The area is: 706.858335 PL/SQL procedure is successfully completed.[/c] The above example describes the PL/SQL standard program for composing multiple line comments.

Summary

shape Key Points

  • PLSQL Comment - A remark is a content that the PL/SQL compiler overlooks.
  • Single line comments - It begins with delimiter in PL/SQL.
  • Multiple line comments - It begins with slash-asterisk and ends with asterisk-slash.