473,545 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ 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_SOUR CE;

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_SOUR CE;

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_SOUR CE
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 10817
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_SOUR CE;

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_SOUR CE;

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_SOUR CE
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
misunderstandin g 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
misunderstandin g 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
19491
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 http://xahlee.org/PageTwo_dir/more.html
11
5218
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"> <tr> <td>abc</td> </tr> </table>
4
4193
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 feature but I can't seem to recreate it at will. I have noticed that it seems as if the projects I upgrade using the wizard have this feature and the...
2
3042
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 what I'm hoping to achieve. I've never before had to use Javascript closures, but now I do, so I'm making an effort to understand them. I've been...
18
2146
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
1984
by: ksukhonosenko | last post by:
This message was originally posted to comp.lang.c++.moderated ---------------------------------------------------------------------------------------------- Hi! I face a problem in my production code. I could deduce this problem to program shown below. It seems, that try-block in constructor doesnt work as it should (compared to case...
3
1492
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 and do transform with another C editor before copying and pasting back
3
2746
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 (line position and char index) in an array of lines of text, how do you Pythonly extract the whole block comment? (Goal: not to have Bruno accusing me -...
0
7408
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7661
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7433
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3458
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.