MichaelB.
7/28/2018 - 12:24 PM

How to use comments or ignore lines

If your SQL statements grow in length and complexity, you need to include comments. Like what the code will do, or provide a developer reference name who developed the code or explain why you are enhancing the code if you're touching somebody else's code. Comments need to be embedded in the script, but not processed by the DBMS. They are only there to understand the code. In HANA there are 2 types of comment:

  • Single line comment: Use two hyphens to ignore a line by placing it in front of the code. Turn the text into comment by placing the hyphens after the code and placing some text after it.
  • Multi-line comment Place /* before the start of the comment and */ after the end
-- Let DBMS ignore a single line

--text


-- Single line comment

statement/identifier -- Comment


-- Multi-line comment

/* comment,
more comments
even more comments */


-- Provide some opening comments to the code

/*
=================================
Reads xyz from such and such
=================================
*/

-- Alternatively (most often used)


-- =================================
-- Reads xyz from such and such
-- =================================