By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,610 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,610 IT Pros & Developers. It's quick & easy.

Comment in an insert statment?

P: n/a
Hello,

I'm looking for a way to make some of my insert templates more readable
by placing comments in between the values. I cannot seem to find a way
to do this with DB2, is there a way? I'm probably missing something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm inserting
have over 100 attributes, so I have to constantly count to see which
attribute I need to look at, and wish to have comments next to each
attribute to tell what it is.
Thanks for any insight.

Ken
Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
73blazer wrote:
Hello,

I'm looking for a way to make some of my insert templates more readable
by placing comments in between the values. I cannot seem to find a way
to do this with DB2, is there a way? I'm probably missing something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm inserting
have over 100 attributes, so I have to constantly count to see which
attribute I need to look at, and wish to have comments next to each
attribute to tell what it is.
Thanks for any insight.

Ken

What you did should work. What client interface are you using?

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

P: n/a
Serge Rielau wrote:
73blazer wrote:
Hello,

I'm looking for a way to make some of my insert templates more
readable by placing comments in between the values. I cannot seem to
find a way to do this with DB2, is there a way? I'm probably missing
something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm
inserting have over 100 attributes, so I have to constantly count to
see which attribute I need to look at, and wish to have comments next
to each attribute to tell what it is.
Thanks for any insight.

Ken


What you did should work. What client interface are you using?


By client interface I'm not exaclty sure, for trying to test this I'm
using command line 'db2 -t', my program uses DB2 sqC code
"EXEC SQL EXECUTE IMMEDIATE :Stmt" like entries

either way I get the same error:

-------------------------------
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 unexpcted token "," was found following "2,ID3) values ( 'yo'".
Expected tokens may include: ")". SQLSTATE=42601
-------------------------------

exact insert statment was:
-------------------------------
insert into ken (id1,id2,id3)
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);
-------------------------------
It's DB2 8.2 on AIX 5.3 both client and DB server.
Not sure why it complains about the comma, if I omit the comments it of
course inserts normally. The DB2 doc says you may use simple or
bracketed comments so long as they are not within a delimeter. does the
open and close parentheses qualify as a deliminter?

Thanks for the help.

Ken
Nov 12 '05 #3

P: n/a
73blazer wrote:
Serge Rielau wrote:
73blazer wrote:
Hello,

I'm looking for a way to make some of my insert templates more
readable by placing comments in between the values. I cannot seem to
find a way to do this with DB2, is there a way? I'm probably missing
something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm
inserting have over 100 attributes, so I have to constantly count to
see which attribute I need to look at, and wish to have comments next
to each attribute to tell what it is.
Thanks for any insight.

Ken

What you did should work. What client interface are you using?


By client interface I'm not exaclty sure, for trying to test this I'm
using command line 'db2 -t', my program uses DB2 sqC code
"EXEC SQL EXECUTE IMMEDIATE :Stmt" like entries

either way I get the same error:

-------------------------------
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 unexpcted token "," was found following "2,ID3) values (
'yo'".
Expected tokens may include: ")". SQLSTATE=42601
-------------------------------

exact insert statment was:
-------------------------------
insert into ken (id1,id2,id3)
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);
-------------------------------
It's DB2 8.2 on AIX 5.3 both client and DB server.
Not sure why it complains about the comma, if I omit the comments it of
course inserts normally. The DB2 doc says you may use simple or
bracketed comments so long as they are not within a delimeter. does the
open and close parentheses qualify as a deliminter?

Thanks for the help.

Ken

Interesting. You can definitely do this inside of an SQL Procedure.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

P: n/a
73blazer wrote:
Serge Rielau wrote:
73blazer wrote:
Hello,

I'm looking for a way to make some of my insert templates more
readable by placing comments in between the values. I cannot seem to
find a way to do this with DB2, is there a way? I'm probably missing
something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm
inserting have over 100 attributes, so I have to constantly count to
see which attribute I need to look at, and wish to have comments next
to each attribute to tell what it is.
Thanks for any insight.

Ken


What you did should work. What client interface are you using?


By client interface I'm not exaclty sure, for trying to test this I'm
using command line 'db2 -t', my program uses DB2 sqC code
"EXEC SQL EXECUTE IMMEDIATE :Stmt" like entries

either way I get the same error:

-------------------------------
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 unexpcted token "," was found following "2,ID3) values (
'yo'".
Expected tokens may include: ")". SQLSTATE=42601
-------------------------------

exact insert statment was:
-------------------------------
insert into ken (id1,id2,id3)
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);
-------------------------------
It's DB2 8.2 on AIX 5.3 both client and DB server.
Not sure why it complains about the comma, if I omit the comments it of
course inserts normally. The DB2 doc says you may use simple or
bracketed comments so long as they are not within a delimeter. does the
open and close parentheses qualify as a deliminter?


I think it complains about the comma because db2 doesn't know what to do
with and the things that come afterwards, which happens to be nothing at
all. My guess is that the newline characters are removed so that
everything after the first comment is treated as part of the comment,
giving an incomplete SQL statement.

I just tried it with this:

insert into ken (id1,id2,id3)
values (
'yo', /* id1 */
'yo', /* id2 */
'ma' /* id3 */
);

That worked quite fine for me (as opposed to the original version).

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #5

P: n/a
Knut Stolze wrote:
73blazer wrote:

Serge Rielau wrote:

73blazer wrote:
Hello,

I'm looking for a way to make some of my insert templates more
readable by placing comments in between the values. I cannot seem to
find a way to do this with DB2, is there a way? I'm probably missing
something basic.

I have

insert into ken.snyder id1,id2,id3
values (
'yo',
'yo',
'ma'
);

I'd like

insert into ken.snyder id1,id2,id3
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);

The reason is I have to keep some insert templates for a program I
wrote, because they change often, and some of these tables I'm
inserting have over 100 attributes, so I have to constantly count to
see which attribute I need to look at, and wish to have comments next
to each attribute to tell what it is.
Thanks for any insight.

Ken

What you did should work. What client interface are you using?


By client interface I'm not exaclty sure, for trying to test this I'm
using command line 'db2 -t', my program uses DB2 sqC code
"EXEC SQL EXECUTE IMMEDIATE :Stmt" like entries

either way I get the same error:

-------------------------------
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 unexpcted token "," was found following "2,ID3) values (
'yo'".
Expected tokens may include: ")". SQLSTATE=42601
-------------------------------

exact insert statment was:
-------------------------------
insert into ken (id1,id2,id3)
values (
'yo', -- id1
'yo', -- id2
'ma' -- id3
);
-------------------------------
It's DB2 8.2 on AIX 5.3 both client and DB server.
Not sure why it complains about the comma, if I omit the comments it of
course inserts normally. The DB2 doc says you may use simple or
bracketed comments so long as they are not within a delimeter. does the
open and close parentheses qualify as a deliminter?

I think it complains about the comma because db2 doesn't know what to do
with and the things that come afterwards, which happens to be nothing at
all. My guess is that the newline characters are removed so that
everything after the first comment is treated as part of the comment,
giving an incomplete SQL statement.

I just tried it with this:

insert into ken (id1,id2,id3)
values (
'yo', /* id1 */
'yo', /* id2 */
'ma' /* id3 */
);

That worked quite fine for me (as opposed to the original version).


Thanks much for your replies.
Ok, now I'm really stumped. I tried that as well, still an error. A
different error, but non-the-less an error.

Error is:
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 ",ID3) values ('yo',".
Expected tokens may include: "<term>". SQLSTATE=42601

I tried as well on my lab machine with AIX 5.3 and DB2 8.2.1 and same
result. Must be something I'm doing if 2 db2 people say it works.
Nov 12 '05 #6

P: n/a
73blazer wrote:
I think it complains about the comma because db2 doesn't know what to do
with and the things that come afterwards, which happens to be nothing at
all. My guess is that the newline characters are removed so that
everything after the first comment is treated as part of the comment,
giving an incomplete SQL statement.

I just tried it with this:

insert into ken (id1,id2,id3)
values (
'yo', /* id1 */
'yo', /* id2 */
'ma' /* id3 */
);

That worked quite fine for me (as opposed to the original version).


Thanks much for your replies.
Ok, now I'm really stumped. I tried that as well, still an error. A
different error, but non-the-less an error.

Error is:
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 ",ID3) values
('yo',". Expected tokens may include: "<term>". SQLSTATE=42601

I tried as well on my lab machine with AIX 5.3 and DB2 8.2.1 and same
result. Must be something I'm doing if 2 db2 people say it works.


I'm running this on Linux (SUSE 9.3) and on DB2 8.2.3. I wrote the
statement into a file and used:

db2 -t -f <file>

(Just for you to compare the environment.)

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #7

P: n/a
Knut Stolze wrote:
73blazer wrote:

I think it complains about the comma because db2 doesn't know what to do
with and the things that come afterwards, which happens to be nothing at
all. My guess is that the newline characters are removed so that
everything after the first comment is treated as part of the comment,
giving an incomplete SQL statement.

I just tried it with this:

insert into ken (id1,id2,id3)
values (
'yo', /* id1 */
'yo', /* id2 */
'ma' /* id3 */
);

That worked quite fine for me (as opposed to the original version).


Thanks much for your replies.
Ok, now I'm really stumped. I tried that as well, still an error. A
different error, but non-the-less an error.

Error is:
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 ",ID3) values
('yo',". Expected tokens may include: "<term>". SQLSTATE=42601

I tried as well on my lab machine with AIX 5.3 and DB2 8.2.1 and same
result. Must be something I'm doing if 2 db2 people say it works.

I'm running this on Linux (SUSE 9.3) and on DB2 8.2.3. I wrote the
statement into a file and used:

db2 -t -f <file>

(Just for you to compare the environment.)


Yep, tried that from a file using db2 -t -f too, same error. I'm
looking, problems like this really annoy me. I'll find it....

Nov 12 '05 #8

P: n/a
73blazer wrote:
Knut Stolze wrote:
73blazer wrote:

I think it complains about the comma because db2 doesn't know what
to do
with and the things that come afterwards, which happens to be
nothing at
all. My guess is that the newline characters are removed so that
everything after the first comment is treated as part of the comment,
giving an incomplete SQL statement.

I just tried it with this:

insert into ken (id1,id2,id3)
values (
'yo', /* id1 */
'yo', /* id2 */
'ma' /* id3 */
);

That worked quite fine for me (as opposed to the original version).
Thanks much for your replies.
Ok, now I'm really stumped. I tried that as well, still an error. A
different error, but non-the-less an error.

Error is:
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 ",ID3) values
('yo',". Expected tokens may include: "<term>". SQLSTATE=42601

I tried as well on my lab machine with AIX 5.3 and DB2 8.2.1 and same
result. Must be something I'm doing if 2 db2 people say it works.


I'm running this on Linux (SUSE 9.3) and on DB2 8.2.3. I wrote the
statement into a file and used:

db2 -t -f <file>

(Just for you to compare the environment.)


Yep, tried that from a file using db2 -t -f too, same error. I'm
looking, problems like this really annoy me. I'll find it....

I think /* */ was introduced for general SQL statements in FP9.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.