Single-Line Comments
A Single line comment starts with the (–) double hyphen. It will affect the whole line (till end of line). We don’t need to specify the end.
Syntax of Single-Line PL/SQL Comment
-- This is a single line comment
Example 01: PL/SQL Program to illustrate Single-Line Comment
-- Here is a program for addition of two numbers in PL/SQL
DELIMITER //
CREATE PROCEDURE add_two_numbers()
BEGIN
-- Declare variables a, b, and c of datatype INT
DECLARE a INT;
DECLARE b INT;
DECLARE c INT;
-- Assign value to variable a
SET a := 10;
-- Assign value to variable b
SET b := 20;
-- Performing addition of a and b and storing it into c
SET c := a + b;
-- Printing the result
SELECT CONCAT('Sum is ', c) AS result;
END //
DELIMITER ;
Output:
Explanation: As we can see after calling the procedure named add_two_numbers, all the comments are ignored by the compiler and the result of addition is returned.
PL/SQL Comments
PL/SQL is a Procedural Language for SQL language that extends the functionality of the SQL within Oracle Database Management System. Comments can be used to make code more human-readable. It is a kind of note that programmers usually add while writing the code. In this article, We will learn about Comments in detail along with the types and benefits of using Comments.
Contact Us