Complex comment sample

<< Click to Display Table of Contents >>

Navigation:  SQL > SQL scripts > Mixed multi/single line comments >

Complex comment sample

Previous pageReturn to chapter overviewNext page

Multi statement complex commenting script sample

To test the PdxEditor capacity to preprocess multiple complex commenting including also single line comments, the following sample may be used as a test script sample and modified as desired for further testing also on error trapping.

SQL script sample to check your SQL parser's detection of commenting syntax errors

-- CREATE TABLE TableA (dummy INTEGER);        -- < do lift commenting if needed
-- This is a test on /* SQL comments */ syntax handling
DROP TABLE /*IF EXISTS*/ TableA;               -- < do lift commenting if needed
/* DROP TABLE IF EXISTS TableB; */
CREATE TABLE TableA (
  IDFieldA INTEGER
, ValueFieldA INTEGER, TextFieldA VARCHAR(20));  /* Some /* other
redundant comments */                          -- < Be aware of SQL Server vs. MySQL
 
/* INSERT INTO TableA VALUES (1,25,'abc');
/* INSERT INTO TableA VALUES (2,26,'def'); */
INSERT INTO TableA VALUES (3,27,'ghi'); */ -- < This (intentionaly added) comment ending should raise error 
-- /* 
INSERT INTO TableA VALUES (4,28,'jkl');
INSERT INTO TableA VALUES (5,29,'mno');
-- */
INSERT INTO TableA VALUES (6,30,'pqr');
INSERT INTO TableA VALUES (7,31,'stu'); -- /* INSERT INTO TableA VALUES (8,32,'vwx');*/
INSERT INTO TableA VALUES (9,33,'zæøå');
-- Display results:
SELECT 
  IDFieldA -- /*  ,ValueFieldA */
 ,TextFieldA
FROM TableA;
/* non-terminated comment      -- < This (intentionaly added) open comment should raise PdxEditor error

The error trapping "/* ..." and "*/" as indicated by red, are added to show how the pre-processing reacts to script comment errors.
Removing the "/* ..." and "*/" as indicated by red, the script should pass the PdxEditor pre-processing.
The script sample has also been tested with MySQL, and passes providing deleting (or -- single line commenting) the line 11 from '*/'.

Note: See Mixed multi/single line comments concerning MS SQL Server.

__________________________
PdxEditor Application Help, 21 May 2026; © 2010-2026 Niels Knabe