Ticker

6/recent/ticker-posts

Comments in Oracle PL/SQL

In this PL/SQL Tutorial, We will explore about the Comments in Oracle PL/SQL.

Comments in Oracle PL/SQL

We will understand about the comments usage in Oracle PL/SQL with helping of some question and answer which are ask often frequently.

What is Comments in Oracle PL/SQL?

Comments is a piece of text placed within the program which describes the aim of code or block. Comments statements ignored by the PL/SQL compiler.

What is the use of Comments in Oracle PL/SQL?

Comments help to others programmer for understanding the logical and conditional statement in your programComments increases the program understandability and readability to other users or developers.

How to Comments help to Others Developers in Oracle PL/SQL?

For this question, we will take an example. Just suppose you are working in the any organisation.Your team manager give to you a any subprogram or named block. Add this logical statement in the named block. But you have not to any idea about existing functionality of the subprogram or named block. If proper comments define by previous or other developer then you can easily understand about the subprogram functionality or behaviour and You could easily add new functionality.

What is the types of Comments in Oracle PL/SQL?

Comments have categorized into two parts.

  1. Single Line Comments
  2. Multiple Line Comments 

Single Line Comments

Double hyphen(--) represent single line comments in a PL/SQL program. It is use for comment single line in the PL/SQL program. Single line comments use anywhere on the line and end of line.

NOTES:- (--) DOUBLE HYPHEN is necessary to add single line comments if you are using single hyphen then program return an error. After the double hyphen you can add more hyphen like this (------).

Example of Single Line Comments in PL/SQL

DECLARE  --VARIABLES DECLARATION
V_NAME VARCHAR2(10):='TEST';
BEGIN
--PRINT VARIABLE VALUE
DBMS_OUTPUT.PUT_LINE(V_NAME);
END;

Multiple Line Comments

Slash-asterisk (/*) represent multiple line comments in PL/SQL program. It is use for one or more lines comment in the PL/SQL program. Multiple line comments necessary to close using asterisk-slash(*/)  otherwise program return an error.

Example of  Multiple Line Comments in PL/SQL

DECLARE   /*VARIABLES DECLARATION*/
V_NAME VARCHAR2(10):='TEST';
BEGIN
/* we don't need to print variable value 
DBMS_OUTPUT.PUT_LINE(V_NAME);
*/
null;
END;

That's all for today, If you like the comments in Oracle PL/SQL post then share your view in the comment section.

Post a Comment

0 Comments