If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > insert question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-01-04, 12:43
rvsc36 rvsc36 is offline
Registered User
 
Join Date: Jan 2004
Location: Phoenix, AZ
Posts: 42
insert question

Hey,

I am trying to update a particular field in a table that is part of the Primary Key for that table. There are 9,386 rows I am trying to update. The current value in the field is 0, and I am trying to turn those values to 2004. When I run the update statement, 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 "6" constrains
table "GLCONSOL" from having duplicate rows for those columns.
SQLSTATE=23505

How is this accomplished?
Thx!
Reply With Quote
  #2 (permalink)  
Old 11-01-04, 13:00
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Primary key are unique by definition. You are changing one or more rows that are trying to make a non-unique primary key value.

Andy
Reply With Quote
  #3 (permalink)  
Old 11-01-04, 13:46
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by rvsc36
Hey,

I am trying to update a particular field in a table that is part of the Primary Key for that table. There are 9,386 rows I am trying to update. The current value in the field is 0, and I am trying to turn those values to 2004. When I run the update statement, 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 "6" constrains
table "GLCONSOL" from having duplicate rows for those columns.
SQLSTATE=23505

How is this accomplished?
Thx!
Check the docs for SQL0803... "db2 ? sql0803", it has this useful query for determining which unique index you're tripping over:

SELECT INDNAME, INDSCHEMA
FROM SYSCAT.INDEXES
WHERE IID = <index-id>
AND TABSCHEMA = 'schema'
AND TABNAME = 'table'

Once you know the index, check the columns and make sure you're update will keep that set of columns unique for all rows.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #4 (permalink)  
Old 11-01-04, 19:05
rvsc36 rvsc36 is offline
Registered User
 
Join Date: Jan 2004
Location: Phoenix, AZ
Posts: 42
Thanks for all of the information. I appreciate everyone's input.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On