Oracle Tips by Burleson
PL/SQL Code Comments
supports two types of comments.
If the commend is only one line, you can use the double hyphen (--) to
mark a line as a comment. Multiple lines can be commented by
bracketing them with the slash star (/*…*/).
2 v_line varchar2(40);
4 -- this is a single line comment
5 v_line := 'Hello World';
6 dbms_output.put_line (v_line);
7 /* This is a
8 multiple line
It has become common to document the code by
adding comments that explain not only what the procedure
(function or block) does but also defines exactly what variables
are passed and how they are changed. This “self documented” code is
invaluable in assisting someone who has to later maintain the code.
Here is a good example.
2 /* This anonymous block uses a SQL*Plus
3 variable as input, appends Hello to
4 the front and writes it out to the
8 1. v_string must be defined before
9 2. Must set serveroutput on to retrieve
12 v_line varchar2(40):= '&v_string';
14 v_line := 'Hello '||v_line;
15 dbms_output.put_line (v_line);
Enter value for v_string: Sammy
v_line varchar2(40):= '&v_string';
new 12: v_line varchar2(40):= 'Sammy';
Next, let’s look at variable declaration and
The above book excerpt is from:
Easy Oracle PL/SQL Programming
Fast with Working PL/SQL Code Examples