Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to update primary key column

WestDraytonDec 28 2010 — edited Jan 4 2011
Hi,
Can you suggest me best workaround/algorithm for below task:

(Oracle 10g, Solaris OS.)
Situation:
Table P has primary key column "Code", child tables F1, F2, ..., F15 reference with foreign key column "P_Code" column "P.Code", and we don't know which of the child tables has data for particular "P.Code" value.
Task:
Change "P.Code" value from 100 to 200. So that result would be that record P[Code = 100] should be updated as:
update P set
Code = 200
where Code = 100;
And child tables column "P_Code" should be updated as:
update F1, F2, .., F15 set
P_code = 200
where P_code = 100;
The best solution would be that one very easily can repeat that task.

Edited by: CharlesRoos on 28.12.2010 12:10
This post has been answered by Toon Koppelaars on Dec 28 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 1 2011
Added on Dec 28 2010
6 comments
7,374 views