Comments

Good practice for any developer in a commercial environment coding PLSQL or indeed any language is the use of comments. Annotating your code allows easy maintenance by yourself should you need to change the code in the future or by other developers.

Syntax

/* Comment in Code */

Example

CREATE OR REPLACE PROCEDURE prc_comment_example AS
-- -------------------------------------------------------------------------
-- PROCEDURE NAME : prc_comment_example
-- PURPOSE : To show how to use comments in PLSQL
--
-- DATE VERSION AUTHOR DESCRIPTION
-- 01/01/1900 1.0 J. Bloggs Initial Development
--
-- -------------------------------------------------------------------------
BEGIN
/* This is the start of the code and we’re showing a different comment */

-- Another comment we’re about to commit the work done.
COMMIT;
END prc_comment_example;

You may well see the /* */ style of comment used in a SQL statement directly after the SELECT reserved word, this is called a hint. It is used when you’re trying to make Oracle use a specific INDEX or manipulate the explain path Oracle takes.

Leave a Reply

Your email address will not be published. Required fields are marked *