We are seeing errors in the DB2 CLP with inline comments. Does anyone know what inline comment syntax is supported in the DB2 command-line processor? We have looked at the DB2 LUW 10.5 Comment Syntax article, and we wrote something like this:
SELECT * FROM sysibm.sysdummy1; --IGNORE-THIS
It works in the tools we tried (e.g. IBM Data Studio) but our DBAs report that it fails in the DB2 CLP (db2
).
This works:
create table testtab (column1 char(1), --IGNORE-THIS
column2 char(1) )
DB20000I The SQL command completed successfully.
This does not:
grant select on table testtab to user someName; --IGNORE-THIS
db2 -tvf test.sql
DB21007E End of file reached while reading the command.
Does anyone know what is wrong here?
It seems it is a feature (restriction) of the CLP only, and the CLP is inconsistent as you described. Might be worth a PMR. In other words the interactive CLI (db2cli) let me run SQLExecDirect() successfully if the statement has the terminator followed by an inline-comment. And the jdbc driver also accepts inline comments (as you found with Data Studio). The doc link that specifies that for CLP -f option allows comments only when the first nonblank characters on the line are -- or /* is : here