View previous topic :: View next topic
|
Author |
Message |
Anand78
New User
Joined: 06 Mar 2006 Posts: 50 Location: PUNE
|
|
|
|
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 |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
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 |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
-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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
As far as I know we can not update a primary key
Anyone please correct me If I am wrong. |
|
Back to top |
|
|
gskulkarni
New User
Joined: 01 Mar 2006 Posts: 70
|
|
|
|
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 |
|
|
Brian's_song
New User
Joined: 27 Dec 2005 Posts: 21
|
|
|
|
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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
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 |
|
|
anamikak
New User
Joined: 10 May 2006 Posts: 64 Location: Singapore
|
|
|
|
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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
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 |
|
|
|