PL/SQL Comments

PLSQL comments are of two types – single line and multi-line.

Single line comments

Single line comments start with ‘–‘ and finish at the end of the line. This type of comment is useful for commenting a particular line of code.
For example:
check_cust_credit; — check limit and no payments over due

The important point to note is that anything after the “–” is considered part of the comment and is therefore ignored by the compiler. 
So this whole line is a comment:
–check_cust_credit; –check limit and no payments over due

The comment doesn’t have to be at the end of the line of code, it could be underneath but obviously it’s worthless if it’s not clear to which line it applies.

To have the comment run over more than 1 line you just need to precede each comment with ‘–‘.
For example:
— this is a 
— comment
— spread over
— multiple lines

Mutli-line comments

The other way to create comments is to wrap them in ‘/*’ and ‘*/’. This type of comment can be dangerous because the comment doesn’t finish automatically at the end of the line, instead it continues until ended with ‘*/’. This makes it easy to create multi-line comments and easy to comment out whole sections of code – either on purpose or accidentally! Note also that you can’t nest comments.

/* So this is
/* just 1 comment
 closed by this tag */

— this is also just /*1*/ comment,everything after– is ignored
/* comments can’t be nested /* this comment ends with */

%d bloggers like this: