473,473 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Block Comment Confusion ...

Again, new to DB2. Trying to do something I can do in Sybase ASE.

In any Sybase SQL script I can use /* */ to comment out a block of
code.

In the DB2 9.0 SQL Reference Manual V1 it says:
Comments: SQL comments are either bracketed (introduced by /* and end
with */) or simple (introduced by two consecutive hyphens and end with
the end of line). Static SQL statements can include host language
comments or SQL comments. Comments can be specified wherever a space
can be specified, except within a delimiter token or between the
keywords EXEC and SQL.
I have this piece of DB2 SQL

connect to DB_PPES;

select count(*) from PPES_REQUEST;

select count(*) from PPES_DISPATCHER;

select count(*) from PPES_ADMIN_SOURCE;

which runs fine. But, when I try to use /* */ to block out the middle
select I get
errors.

So, this:
connect to DB_PPES;

select count(*) from PPES_REQUEST;
/*
select count(*) from PPES_DISPATCHER;
*/
select count(*) from PPES_ADMIN_SOURCE;

produces this:
select count(*) from PPES_REQUEST

1
-----------
369955

1 record(s) selected.
/* select count(*) from PPES_DISPATCHER
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "/* select count(*) from
PPES_DISPATCHER" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<space>". SQLSTATE=42601

*/ select count(*) from PPES_ADMIN_SOURCE
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "*/" was found following "BEGIN-OF-
STATEMENT".
Expected tokens may include: "<space>". SQLSTATE=42601
I realize that I could just put -- in front of the line I want to
comment out, but what if I wanted to
comment out 1000's of lines. The manual says it should work, yet I
can't it to. Our DB2 version is
9.1.0.4. The command I'm executing the query with is "db2 -tf x.sql"

Thanks
Oct 10 '08 #1
3 10808
Richard wrote:
Again, new to DB2. Trying to do something I can do in Sybase ASE.

In any Sybase SQL script I can use /* */ to comment out a block of
code.

In the DB2 9.0 SQL Reference Manual V1 it says:
Comments: SQL comments are either bracketed (introduced by /* and end
with */) or simple (introduced by two consecutive hyphens and end with
the end of line). Static SQL statements can include host language
comments or SQL comments. Comments can be specified wherever a space
can be specified, except within a delimiter token or between the
keywords EXEC and SQL.
I have this piece of DB2 SQL

connect to DB_PPES;

select count(*) from PPES_REQUEST;

select count(*) from PPES_DISPATCHER;

select count(*) from PPES_ADMIN_SOURCE;

which runs fine. But, when I try to use /* */ to block out the middle
select I get
errors.

So, this:
connect to DB_PPES;

select count(*) from PPES_REQUEST;
/*
select count(*) from PPES_DISPATCHER;
*/
select count(*) from PPES_ADMIN_SOURCE;

produces this:
select count(*) from PPES_REQUEST

1
-----------
369955

1 record(s) selected.
/* select count(*) from PPES_DISPATCHER
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "/* select count(*) from
PPES_DISPATCHER" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<space>". SQLSTATE=42601

*/ select count(*) from PPES_ADMIN_SOURCE
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "*/" was found following "BEGIN-OF-
STATEMENT".
Expected tokens may include: "<space>". SQLSTATE=42601
I realize that I could just put -- in front of the line I want to
comment out, but what if I wanted to
comment out 1000's of lines. The manual says it should work, yet I
can't it to. Our DB2 version is
9.1.0.4. The command I'm executing the query with is "db2 -tf x.sql"

Thanks
Use (= and =) to denote block comments. From V9 documentation:

Input file lines which begin with (= are treated as the beginning of a
comment block. Lines which end with =) mark the end of a comment block.
The block of input lines that begins at (= and ends at =) is treated as
a continuous comment by the command line processor. Spaces before (= and
after =) are allowed. Comments may be nested, and may be used nested in
statements. The command termination character (;) cannot be used after =).

Link to documentation page describing this:

http://publib.boulder.ibm.com/infoce...c/r0010410.htm
Jan M. Nelken
Oct 10 '08 #2
Thanks. :-) That worked on my 9.1 server. A coworker tried on an 8.x
server and got
an error with the (= , so I'll assume it only works in 9.x.

So what am I intrepreting incorrectly. In the 9.0 SQL Reference
Manual is says use /* */, yet the CLP manual says (= =). Since I'm
running a SQL script in the CLP, shouldn't either work? Maybe I'm
misunderstanding the audience of the SQL Reference manual.

Thanks.
Oct 10 '08 #3
Richard wrote:
Thanks. :-) That worked on my 9.1 server. A coworker tried on an 8.x
server and got
an error with the (= , so I'll assume it only works in 9.x.

So what am I intrepreting incorrectly. In the 9.0 SQL Reference
Manual is says use /* */, yet the CLP manual says (= =). Since I'm
running a SQL script in the CLP, shouldn't either work? Maybe I'm
misunderstanding the audience of the SQL Reference manual.

Thanks.
To be precise:

SQL Reference states:
SQL comments

Static SQL statements can include host language or SQL comments. Dynamic
SQL statements can include SQL comments. There are two types of SQL
comments:

simple comments
Simple comments are introduced by two consecutive hyphens (--) and
end with the end of line.
bracketed comments
Bracketed comments are introduced by /* and end with */.

The following rules apply to the use of simple comments:

* The two hyphens must be on the same line and must not be
separated by a space.
* Simple comments can be started wherever a space is valid (except
within a delimiter token or between 'EXEC' and 'SQL').
* Simple comments cannot be continued to the next line.
* In COBOL, the hyphens must be preceded by a space.

The following rules apply to the use of bracketed comments:

* The /* must be on the same line and must not be separated by a space.
* The */ must be on the same line and must not be separated by a space.
* Bracketed comments can be started wherever a space is valid
(except within a delimiter token or between 'EXEC' and 'SQL').
* Bracketed comments can be continued to subsequent lines.
Let me show this again:

*Static SQL statements* can include host language or SQL comments.
*Dynamic SQL statements* can include SQL comments.

This would be correct:

select /* I am using
SELECT keyword
*/
count /* I am going
to count
rows
*/
(*) from /* I will use
Sample database
ORG table
here
*/
ORG;
but you *WERE NOT* including bracketed comments in Static or dynamic SQL
statement; you were trying to comment out lines in CLP script - hence
you have to use CLP syntax.
Jan M. Nelken
Oct 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Xah Lee | last post by:
is there a syntax to comment out a block of code? i.e. like html's <!-- comment --> or perhaps put a marker so that all lines from there on are ignored? thanks. Xah xah@xahlee.org...
11
by: Mark Schneider | last post by:
I'm trying to avoid using <table> for formatting purposes where other, reasonable means exist. I'm stuck trying to find a way to find an equivalent for the code below. <table align="center">...
4
by: William | last post by:
I have a question regarding comments. In some of my projects if I have a multi-line comment block I am able to collapse those blocks even if it is within a sub or a function. I like this...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
18
by: John Salerno | last post by:
I'm still tyring to figure out what "Pythonic" means, and I have a feeling the answer to my question may fall into that category. Are block comments somehow unpythonic?
4
by: ksukhonosenko | last post by:
This message was originally posted to comp.lang.c++.moderated ---------------------------------------------------------------------------------------------- Hi! I face a problem in my...
3
by: GS | last post by:
how can one quickly comment out a block of selected code in visual studio express 2005 the insert comment is only good for a block of comment before sub, function right now I would have to cut...
3
by: MartinRinehart | last post by:
Tomorrow is block comment day. I want them to nest. I think the reason that they don't routinely nest is that it's a lot of trouble to code. Two questions: 1) Given a start and end location...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.