KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to add comments in an SQL statement
PRODUCT: 4D | VERSION: 11 | PLATFORM: Mac & Win
Published On: November 25, 2008

It is very easy to add comments inside an SQL statement. Just surround the comment with "/*" and "*/". Here are a couple examples of SQL statements using comments:

Example 1:



C_TEXT($vName;$vresult)
C_Pointer($name_p)


BEGIN SQL
        /*This is a comment*/
          SELECT /* This is the Field*/names
          FROM /*This is the Table*/test
          WHERE /*This is the variable*/names =:$name_p
          INTO :/*result*/$vresult
       /*End*/
END SQL


Example 2:


C_TEXT(statement)

statement:="/*This is a comment*/ "
statement:=statement + "SELECT/* This is the Field*/names "
statement:=statement +  "FROM/*This is the Table*/test "
statement:=statement + "WHERE /*This is the variable*/names =:$name_p "
statement:=statement + "INTO/*This is the result*/ :$vresult "
statement:=statement + " /*End*/"

BEGIN SQL
        execute immediate :statement;
END SQL

Commented by Silvio Belini on April 16, 2009 at 11:25 AM
You can also have multiline comments by adding /* in the beginning of the first comment line and */ at the end of the last comment line (No need to add /* and */ in every single line).