473,503 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help with INSERT

3 New Member
Using DB2 LUW v9.7, I have a table where the primary key is an identity column, generated by DEFAULT NO CYCLE . COL1 is the key, COL2, COL3 and COL4 are the remaining columns. An index is created on COL1. No other index exists.

But I can't insert data into it.

I write the insert like this, skipping the first column so DB2 will pick the value:

insert into mytable (col2, col3, col4) values (1,6,'some_text')"

...and I get this:


DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the
primary key, unique constraint or unique index identified by "1" constrains table "MYSCHEMA.MYTABLE" from having duplicate values for the index key.
SQLSTATE=23505

What am I doing wrong???

Thanks,

George
Apr 30 '15 #1
3 1913
gdevelek
3 New Member
I figured this out, please disregard it and sorry for your time.
Apr 30 '15 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Can you post your solution in case someone else runs into the same problem?
Apr 30 '15 #3
gdevelek
3 New Member
Earlier I had inserted some data where the id column was provided explicitly. When later I attempted to insert data using the autoincrement feature, a conflict occurred when the "next value" was already taken by the initial data.

Obviously that's a risk one takes when using the BY DEFAULT clause.
Apr 30 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

18
2271
by: deancoo | last post by:
I have gotten into the habit of often using copy along with an insert iterator. There are scenarios where I process quite a lot of data this way. Can someone give me a general feel as to how much...
1
5601
by: Christian Soltenborn | last post by:
Hi experts, I am working on a university project based on VB .NET. I have a connection to MS Access, and I want to insert some data into the database. The sql command INSERT INTO Shoe (Brand,...
1
1449
by: Lee Holsenbeck | last post by:
hi, i am trying to write records from an ASPX page to a access database, but get an error on my insert statement, but not on a select statement. please let me know if you can see what i'm doing...
2
3824
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3=...
1
5542
by: masri999 | last post by:
Hello, I want to share my experiences about using insert into exec which may help others . Using SQL Server 2000, SP3 . Two Proceduers - Parent SP caliing a Child SP (nested ) . No...
0
1003
by: deepaks85 | last post by:
Dear Friends, I have an asp script which help me to upload the file into my FTP server but I need to insert records to my MSSQL database also. Plz help me that what exactly should I do if I want...
1
1042
by: arial | last post by:
I have two problem. 1) My insert statement here is not working. It is not inserting value into the database. I am not getting any error message but I can not figured out why it is not...
2
3722
by: lenygold via DBMonster.com | last post by:
Hi Everebody: I have a table: CREATE TABLE CROSS_REFERENCE (ROW# INTEGER NOT NULL ,KEY_WORD CHAR(16) NOT NULL ,QUERY_DESCR VARCHAR(330) NOT NULL ,PRIMARY KEY (ROW#,KEY_WORD)); It is a...
2
1631
by: Joe Y | last post by:
I created a button, when clicked, supposed to create a new record on a different form which is bound to table ‘TProduct’. Values from these text boxes are to be inserted in to new record in...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7315
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
6974
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
5559
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,...
1
4991
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...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
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 ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.