DB2 Server for VSE & VM: Application Programming


SQL Comments within Static SQL Statements

You can use a comment as a separator within static SQL statements written in the various host languages. This comment is referred to as an SQL comment (as opposed to host language comments), and is identified by two consecutive hyphens (--) on the same line, not separated by a space and not part of a literal, a string of DBCS characters, a quoted identifier, or an embedded host language comment. In COBOL, the two hyphens must be preceded by a blank. The comment ends at the end of the line.

Here is the sample query from the previous discussion on UNION, documented with a few SQL comments:

   SELECT PROJNO,'MEAN'
   FROM PROJ_ACT -- PROJECT ACTIVITY TABLE
   WHERE ACSTAFF > .50
   -- FIRST QUERY IS FOR ESTIMATED MEAN NUMBER OF EMPLOYEES
   UNION
   -- SECOND QUERY IS FOR PROPORTION OF EMPLOYEE TIME
   SELECT PROJNO,'PROPORTION'
   FROM EMP_ACT -- EMPLOYEE ACTIVITY TABLE
   WHERE EMPTIME > .50

The DB2 Server for VSE & VM SQL Reference manual for the detailed syntax rules on the use of SQL comments within application programs.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]