dbTalk Databases Forums  

Seek query to find out the contraint that evokes a SQLCODE -803 error

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Seek query to find out the contraint that evokes a SQLCODE -803 error in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gimme_this_gimme_that@yahoo.com
 
Posts: n/a

Default Seek query to find out the contraint that evokes a SQLCODE -803 error - 08-18-2010 , 08:55 PM






With this error message:

SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 34;MJPP.PPL

Is there a sysibm query which tells you what constraint 34 is?

Thanks.

Reply With Quote
  #2  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: Seek query to find out the contraint that evokes a SQLCODE -803error - 08-19-2010 , 12:15 AM






On 2010-08-19 03:55, gimme_this_gimme_that (AT) yahoo (DOT) com wrote:
Quote:
With this error message:

SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 34;MJPP.PPL

Is there a sysibm query which tells you what constraint 34 is?

Thanks.

If you look at SQLSTATE 23505 it doesn't tell us much:

[lelle@c-83-219-209-129 ~]$ db2 "? 23505"

SQLSTATE 23505: A violation of the constraint imposed by a unique index
or a
unique constraint occurred.


However, a trick is to ask for the meaning of -803 as in:

[lelle@c-83-219-209-129 ~]$ db2 "? SQL803"

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 "<index-id>" constrains table "<table-name>" from
having duplicate values for the index key.

Explanation:

The INSERT or UPDATE object table "<table-name>" is constrained by one
or more UNIQUE indexes to have unique values in certain columns or
groups of columns. Alternatively, a DELETE statement on a parent table
caused the update of a foreign key in a dependent table "<table-name>"
that is constrained by one or more UNIQUE indexes. Unique indexes might
support primary keys or unique constraints defined on a table. The
statement cannot be processed because completing the requested INSERT,
UPDATE or DELETE statement would result in duplicate column values. If
the index is on an XML column, the duplicate values for the index key
may be generated from within a single XML document.

Alternatively, if a view is the object of the INSERT or UPDATE
statement, it is the table "<table-name>" on which the view is defined
that is constrained.

If "<index-id>" is an integer value, the index name can be obtained from
SYSCAT.INDEXES by issuing the following query:

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

where schema represents the schema portion of "<table-name>" and table
represents the table name portion of "<table-name>".

[...]

In this case I would start with:

select INDNAME, INDSCHEMA
from syscat.indexes
where iid = 34
and tabschema = 'MJPP'
and tabname = 'PPL';

/Lennart

Reply With Quote
  #3  
Old   
gimme_this_gimme_that@yahoo.com
 
Posts: n/a

Default Re: Seek query to find out the contraint that evokes a SQLCODE -803 error - 08-19-2010 , 11:56 AM



Thank you. Thank you. Lennart Jonsson.

This allowed me to identify this as the primary key constraint and
investigate that insert is being attempted instead of an update.

Quote:
In this case I would start with:

select INDNAME, INDSCHEMA
from syscat.indexes
where iid = 34
* and tabschema = 'MJPP'
* and tabname * = 'PPL';

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.