473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Comment in an insert statment?

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
8 2019
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: soni29 | last post by:
hi, i have a small question regarding sql, there are two tables that i need to work with on this, one has fields like: Table1: (id, name, street, city, zip, phone, fax, etc...) about 20 more...
1
by: Maria | last post by:
Hello I have not used db2 in a long time, and I have this very long insert script, which is giving me an error of duplicated inserts. My question is how can I put something in the statment so...
2
by: 73blazer | last post by:
Perhaps my thinking is wrong but this is what I have: 1 table (Tab1) with 1 attribute (Attr1) Attr1 char(16) for bit data ----------------------------------------------- create trigger...
10
by: Daniel P. | last post by:
How can I use ADO.NET to insert lots of records in a very fast way? Thanks!
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
2
by: Denis Correard | last post by:
I have an application that create an insert statment on the fly (it would be to complex to create stored procedures for all senarios) like: insert into Table (field1, field2,field3 ,field4 ) VALUES...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
8
by: slb813 | last post by:
Hello, I am having a problem that I can't seem to work out. I am running Apache 2.2 on a Windows XP platform, using PHP5. I am attempting to insert a row into a MS Access data base with a PHP...
39
by: polas | last post by:
Afternoon all. I was just wondering about this point - I have (generally) used // for commenting a single line in C, but from looking at code other people have written it seems many use /* */...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.