IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 sqlcode -803 querry


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Anand78

New User


Joined: 06 Mar 2006
Posts: 50
Location: PUNE

PostPosted: Tue Apr 25, 2006 1:16 pm
Reply with quote

Pls see my problem below,

I need to update primary key of table T1,

Say,,,

DPCI (col of primary key)

A01
B01
C01
...

I want to update A01 to C01 and C01 to any other keys ,
How to handle -803 sqlcode?

Pls take on priority.

regards
ANAND
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Tue Apr 25, 2006 1:23 pm
Reply with quote

Hi,

First update the C01 record to some other and then go ahead with the A01

Is this is going to help you..


Correct me if I am wrong


Thanks
Shri
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Tue Apr 25, 2006 1:45 pm
Reply with quote

Try this query

UPDATE T1
SET C01 = X02
WHERE DPCI = 'C01';

then

UPDATE T1
SET A01 = C01
WHERE DPCI = 'A01';

Correct me if I am wrong


Thanks
Shri
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Mon Jun 05, 2006 12:22 pm
Reply with quote

-803 si thrown when you try to insert a row with existing primary key value(i.e. duplicate). If you want insert again for the same key then either you delete the previous row and insert or update the same row with new values for other columns
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Mon Jun 05, 2006 12:26 pm
Reply with quote

As far as I know we can not update a primary key

Anyone please correct me If I am wrong.
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Mon Jun 05, 2006 2:26 pm
Reply with quote

One can not update the primary index of table, sam e as one can not update the primary key of KSDS.
Option 1. In your program, delete the row, and insert with new index value with otehr column data remaining the same. This will serve as good as replace.

option 2.
You can unload the table using LOAD/UNLOAD, update the sequential file that has unloaded table data with desired values at desired columns. and then LOAD the table using LOAD/UNLOAD utility.
Back to top
View user's profile Send private message
Brian's_song

New User


Joined: 27 Dec 2005
Posts: 21

PostPosted: Mon Jun 05, 2006 7:22 pm
Reply with quote

Hi ,

I always update the primary key of a table and it is successfully updated.
I think we can update the primary key of a table except for the parent table's primary key.
Any one Pls correct me if I am wrong.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Tue Jun 06, 2006 3:32 pm
Reply with quote

Brian's_song wrote:
Hi ,

I always update the primary key of a table and it is successfully updated.
I think we can update the primary key of a table except for the parent table's primary key.
Any one Pls correct me if I am wrong.


Hi Brian's_song,

I do not understand waht you mean by

'I think we can update the primary key of a table except for the parent table's primary key.'
but you can never update a primary key.
Back to top
View user's profile Send private message
anamikak

New User


Joined: 10 May 2006
Posts: 64
Location: Singapore

PostPosted: Wed Jun 07, 2006 4:17 pm
Reply with quote

Prasad,

Brian is referring to rules of Referential integrity where in the foreign key of a child table is dependant on the primary key of the parent table. so if there are dependant tables,Db2 will not allow the updation of primary key of the parent table.

anamika
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Wed Jun 07, 2006 4:24 pm
Reply with quote

How would it be primary key then it will be foreign key which can be either nullable or updatable as long as the new value exists in the referred table.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SQLCODE = -122 while using the scalar... DB2 4
No new posts SQLCODE = -16002 when using XMLEXISTS DB2 1
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
No new posts Getting sqlcode 805 while executing R... DB2 10
Search our Forums:

Back to Top