Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 sqlcode -803 querry

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 sqlcode -803 querry
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: 171
Location: Bangalore

PostPosted: Tue Apr 25, 2006 1:23 pm    Post subject:
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: 171
Location: Bangalore

PostPosted: Tue Apr 25, 2006 1:45 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQLCODE-000000080N priya91 DB2 1 Mon Feb 01, 2016 4:35 pm
No new posts Need to understand SQLCODE = 12 rohanthengal DB2 3 Thu Nov 05, 2015 11:22 am
No new posts SQLCODE -922 in Batch-Cics program tr... kishpra CICS 2 Thu Sep 10, 2015 12:36 pm
No new posts to extract node name from XML via DB2... Gopalakrishnan V DB2 3 Mon Aug 31, 2015 1:58 pm
No new posts SQLCODE -450 for stored procedure spoorni DB2 3 Fri Jan 16, 2015 2:45 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us