Mixed multi/single line comments

<< Click to Display Table of Contents >>

Navigation:  SQL > SQL scripts >

Mixed multi/single line comments

Previous pageReturn to chapter overviewNext page

Multi line and single line comments in same script

As a general precaution: don't mix standard comment delimiters /* */ and single line markings -- in between each other, and do avoid nested comments only accepted by some database systems.

With PdxEditor multi line and single line comments are accepted mixed within the same SQL statements or scripts.
With PdxEditor vers. 5.5 the handling of mixed comments have been tweaked to comply in detail with standards for comment handling with that of e.g. MySQL and SQLite (MySQL however demanding space or control character after '--').
Some of the script samples below may be considered as poor coding style, but are deliberately designed to test error detection and parsing behaviour.

Clean Up Complex Comment Marking

To be processed by the Paradox (BDE) engine, statements with single line comments ( '--' ) as well all SQL scripts must be preprocessed as selected by the menu SQL/SQL Editor Options/Clean Up Complex ...
This clean up process clearing all accepted syntax markings but leaving out non-pairing start (/*) or end (*/) comment markers.
See Comment Clean Up Preview

General SQL rule on */ comments closing

Universally the end comment marker (*/) will be considered active when following an unterminated/unclosed comment, irrespective it may itself within the same line be commented by a preceding single line/inline comment marker (-- ).
See comment examples below.

PdxEditor/MySQL/SQLite/SQL Server standard SQL mixed comment handling

INSERT INTO TableA VALUES (25,1);
/*INSERT INTO TableA VALUES (26,2);
-- INSERT INTO TableA VALUES (27,3);*/ --< */ terminates multi line comment disregarding the single line comment
INSERT INTO TableA VALUES (28,4);*/   --< raises an error due to non-paired end comment marker
INSERT INTO TableA VALUES (29,5);  
INSERT INTO TableA VALUES (30,6);

whereas Firebird (and Interbase?) has a very strange interpretation of the script lines above by inserting line 1, 4 and 6, but not line 5.

Problematic complex mixed comment handling

Some SQL comments are interpreted differently between database systems, e.g.:
MySQL / SQLite / PdxEditor vs. MS SQL Server

Whereas some (e.g. PdxEditor, MySQL and SQLite) will for any open comment character (/*) search for a pairing subsequent closing comment character (*/) ignoring interposed (redundant) open comment character pairs (/*), and will thus interprete the statement as below (green = comment) and raising an error as indicated:

INSERT INTO TableA VALUES (25,1);
/*INSERT INTO TableA VALUES (26,2);
/* some redundant comments */        --< /* considered redundant, and */ closing the comment
INSERT INTO TableA VALUES (27,3);*/  --< raises an error due to non-paired end comment marker
INSERT INTO TableA VALUES (28,4);

whereas MS SQL Server will accept nested comments and will accordingly interprete the following:

INSERT INTO TableA VALUES (25,1);
/*INSERT INTO TableA VALUES (26,2);  --< interpreted as start of outer comment
/* some redundant comments */        --< interpreted as nested comment
INSERT INTO TableA VALUES (27,3);*/  --< interpreted as end of outer comment
INSERT INTO TableA VALUES (28,4);

whereas Firebird (here too) (and Interbase?) has a very strange interpretation of the script lines above by inserting line 1 and 4 but not line 5.

Also, with many database systems including PdxEditor and MySQL, the bloc below is considered legal code

INSERT INTO TableA VALUES (1,250,'abc');
/* INSERT INTO TableA VALUES (2,260,'def');
/* INSERT INTO TableA VALUES (3,270,'ghi'); */
INSERT INTO TableA VALUES (4,280,'jkl');

whereas with MS SQL Server the bloc is invalid, as interpreted having an unterminated outer comment.

Warning: Also, MS SQL Server as well as PostgreSQL meeting this (/* .../* ... */) will not close the comment untill finding the second paired closing */, and in this way may unintentionally inactivate several following code lines (or the rest of the script), thus significantly differing from e.g. MySQL, SQLite, BDE/Paradox and others!

Comment examples

Generally the following commenting will by all the DBMSs mentioned be uniformly accepted:
/*
INSERT INTO TableA VALUES (30,6);
*/
-- */

as well as this
-- /*
INSERT INTO TableA VALUES (30,6);
-- */
-- */

as well as this
/*
INSERT INTO TableA VALUES (30,6);
-- */
-- */

but NONE will accept this:
/*
INSERT INTO TableA VALUES (30,6);
-- */
*/                                 --< raises an error due to non-paired end comment marker

As a general rule, care should be taken when using or reading SQL statements with complex commenting across database systems.

So, to ensure valid cross platform SQL commenting, do avoid nested comments (/*.../*...*/...*/) and do remember to check a space or control character (e.g. #9 = tab) after the single line comment marker (-- ) as required by MySQL.

_________________________________
Firebird SQL notes:
‡ : fbclient.dll and engine13.dll both ver. 5.0.3, and whatever the application is generated with FireDAC/Delphi 10.4.2 or with FireDAC/Delphi 12.

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