How can I update the primary key column

Hello
Can you suggest me best workaround/algorithm for task below:

(Oracle 10g, Solaris OS.)
Location:
Table a primary key column P 'Code', tables children F1, F2,..., reference to F15 "Code_P' foreign key column"P.Code"column, and we do not know which of the child tables data available for a particular value"P.Code.
Task:
Change the value "P.Code" from 100 to 200. So that the result would be that record P [Code = 100] should be updated:
update P set
Code = 200
where Code = 100;
And child tables 'Code_P' column should be updated as:
update F1, F2, .., F15 set
P_code = 200
where P_code = 100;
The best solution would be that you can easily repeat this task.

Edited by: CharlesRoos the 28.12.2010 12:10

Will there be FK constraints in place?
If so, you may need to modify them so that their application may be temporarily deferred.

The gameplan would be something like this:

-Making of CF can be deferred, immediate departure.
-Alter FK set delay.
-Update of Parent table.
-Update of the children tables.
-Immediate constraints set
s ' engage;

Tags: Database

Similar Questions

  • How to refer to the primary key column of newly inserted rows of tabular form

    Hello

    I use APEX 4.2.0.00.27 with Oracle DB 11.2.0.3.0.

    I work with a tabular presentation wizard-created for insert and update a table using the integrated SRM process (sequence 10).  I'm trying to use a process of anonymous block of PL/SQL (sequence 30) to make another manipulation of table after the records were inserted or updated.  The manual process is associated with my tabular form and I use the variables of name of column binding in my program block.

    My (rsn_test) table has 3 columns: test_id (number), test_nbr (number), test_id2 (number).  Test_id column is identified as the primary key and the type of the source already exists a sequence rsn_test_seq.  Column test_id2 gets its default value 0 to a hidden page element.

    I would use my manual process for updating the value of the test_id2 column.  If it's 0 then I want to put the value of the column test_id.  If it is any other value, then it must remain at this value.  My logic works very well for an existing line, but I'm running into a problem with the newly added lines.  The new lines get inserted, but the test_id2 column remains the default value 0.  I can tell the debugger that the SRM process is triggered first and inserts the line, then my manual dealing with fires.  The problem seems to be that the connection variable: TEST_ID for the primary key column remains NULL after insertion.  I don't know how to get the value of the column test_id of my newly created line to use in my PL/SQL block to my update.

    Process of PL/SQL:

    DECLARE
    BEGIN
       :P7_SHOW := NULL;
       :P7_SHOW := NVL(:TEST_ID2,555) || ' and ' || NVL(:TEST_ID,787) || ' and ' || NVL(:TEST_NBR,9999);
       IF :TEST_ID2 = 0 AND :TEST_ID IS NOT NULL THEN
          UPDATE rsn_test
             SET test_id2 = :TEST_ID
           WHERE test_id = :TEST_ID;
       ELSE
          :TEST_ID2 := :TEST_ID2;
       END IF;
    END;
    
    

    Excerpt from the debugger:

    0.01625 0.00010 Processes - point: ON_SUBMIT_BEFORE_COMPUTATION
    0.01635 0.00008 Branch point: Before Computation
    0.01643 0.00003 Process point: AFTER_SUBMIT
    0.01646 0.00022 Tabs: Perform Branching for Tab Requests
    0.01668 0.00008 Branch point: Before Validation
    0.01676 0.00024 Validations:
    0.01700 0.00135 Perform basic and predefined validations:
    0.01835 0.00020 Perform custom validations:
    0.01855 0.00049 ...Validation "TEST_NBR must be numeric" - Type: ITEM_IS_NUMERIC
    0.01904 0.00007 ......Skip for row 1 because row hasn't changed
    0.01911 0.00016 ......Skip for row 2 because row hasn't changed
    0.01927 0.00012 ...Validation "TEST_ID2 must be numeric" - Type: ITEM_IS_NUMERIC
    0.01939 0.00007 ......Skip for row 1 because row hasn't changed
    0.01945 0.00018 ......Skip for row 2 because row hasn't changed
    0.01964 0.00005 Branch point: Before Processing
    0.01968 0.00004 Processes - point: AFTER_SUBMIT
    0.01972 0.00588 ...Process "ApplyMRU" - Type: MULTI_ROW_UPDATE
    0.02560 0.00154 ...Execute Statement: declare function x return varchar2 is begin begin for c1 in ( select "RSN_TEST_SEQ".nextval pk from sys.dual ) loop return c1.pk; end loop; end; return null; end; begin wwv_flow.g_value := x; end;
    0.02714 0.00140 ......Row 3: insert into "APPPCSRSN"."RSN_TEST" ( "TEST_ID", "TEST_NBR", "TEST_ID2") values ( :b1, :b2, :b3)
    0.02854 0.00011 ...Process "ApplyMRD" - Type: MULTI_ROW_DELETE
    0.02865 0.00004 ......Skip because condition or authorization evaluates to FALSE
    0.02869 0.00015 ...Process "Process Submit" - Type: PLSQL
    0.02884 0.00007 ......Skip for row 1 because row hasn't changed
    0.02891 0.00012 ......Skip for row 2 because row hasn't changed
    0.02903 0.00012 ......Process row 3
    0.02915 0.00429 ...Execute Statement: begin DECLARE BEGIN :P7_SHOW := NULL; :P7_SHOW := NVL(:TEST_ID2,555) || ' and ' || NVL(:TEST_ID,787) || ' and ' || NVL(:TEST_NBR,9999); IF :TEST_ID2 = 0 AND :TEST_ID IS NOT NULL THEN UPDATE rsn_test SET test_id2 = :TEST_NBR WHERE test_id = :TEST_ID; ELSE :TEST_ID2 := :TEST_ID2; END IF; END; end;
    0.03344 0.00013 ...Session State: Saved Item "P7_SHOW" New Value="0 and 787 and 1300"
    0.03356 0.00004 Branch point: After Processing
    0.03360 0.00048 ...Evaluating Branch: "AFTER_PROCESSING" Type: REDIRECT_URL Button: (No Button Pressed) Condition: (Unconditional)
    0.03407 0.00013 Redirecting to f?p=290:7:8717971109610:::::&success_msg=0%20row(s)%20updated%2C%201%20row(s)%20inserted.Success%2FEBD244168556408CBA714E3974918C09%2F
    0.03420 0.00012 Stop APEX Engine detected
    0.03432 0.00007 Stop APEX Engine detected
    0.03439 - Final commit
    
    

    Any suggestions?

    I have run tests on

    https://apex.Oracle.com/pls/apex/f?p=83488:1 demo/demo

    to see your problem.

    I have 2 solution for your problem.
    I add trial NOT tabular just usual block of PL/SQL

    BEGIN
    I'm IN (SELECT TEST_ID FROM RSN_TEST WHERE TEST_ID2 = 0)
    LOOP
          UPDATE RSN_TEST
             SET test_id2 = TEST_ID
           WHERE test_id = i.TEST_ID;
      END LOOP;
    END;

    and works very well, you can see in the sample.

    The other solution is to show new generated TEST_ID

    Adding a sequence as a default value for a column in a table field

    And to execute your procedure.

    I get how is with the good luck of time.

    By

  • How to convert a single column in the primary key column

    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant wrote:
    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant,

    You must assign new values to null values. You can use a sequence to produce the figures in this column.

    Select max (your_unique_column) from your_table; -find the maximum value of this column, so you can start the sequence of this number.

    create sequence seq_for_your_table with XXXX - value max + 1 you have found

    Update your_table set your_unique_column = seq_for_your_table.nextval () where your_unique_column is null

    You can create a primary key on this column.

    Best regards

    Grosbois

    -------------------------------------------------------
    If you answer this question, please mark appropriate as correct/useful messages and the thread as closed. Thank you

  • How to find the primary key columns in the tables in MS Access using SQL queries

    How to find the primary key columns in the tables in MS Access using SQL queries

    Hello

    This is the forum for Windows Vista programs related issues.

    For better assistance, please try instead the Forums in SQL Server .

    Thank you! Vincenzo Di Russo - Microsoft MVP Windows Internet Explorer, Windows Desktop Experience & security - since 2003. ~ ~ ~ My MVP profile: https://mvp.support.microsoft.com/profile/Vincenzo

  • How can I get the product key online for the vista sp2 update which is not genuine

    How can I get the product key for activation of vista sp2 update which is not genuine online?

    Khaled, you know something that is not Microsoft. Well, I hope that you are not a Microsoft Support Engineer.

    Copied from the Microsoft Web site...

    The purchase of Windows Vista
    Microsoft sells more than Windows Vista, although we will continue to support.
    Visit your local retailer or online to buy a PC with Windows Vista
    .

  • best method to update the primary key

    Can someone tell me the best possible method to update the primary key so that the foreign key is also updated.
    Please explain with example

    940340 wrote:
    Can someone tell me the best possible method to update the primary key so that the foreign key is also updated.
    Please explain with example

    You're after a mechanism that lets you update the primary key sometimes on some lines, or did you just impossible, which means that you must update all the data because of some kind of change in the structural definition?

    If all you need is a rational method to change keys sometimes (and this isn't quite mortal sin that other posters have been suggesting) then recreate your foreign key as a constraint can be delayed may help.

    Oracle allows no you cascading updates automatically for primary keys, but if the foreign key is carried forward you can proceed as follows:

    set constraint {foreign key constraint name} deferred;
    update parent primary key;
    update child foreign key;
    set constraint {foreign key constraint name} immediate;
    

    Concerning
    Jonathan Lewis

  • Satellite L300D - 24 d how can I update the graphics driver?

    Hello

    How can I update the driver for my ATI Radeon 3100 graphics card. (Win Vista 32 bit)
    I download and installed the new ATI Catalyst worms. 10.12.

    If I change my graphics card options, there is always the old driver installed... Worms. 22.04.08 8.479.0.0
    Also, it is not possible to change the settings for graphic resolution higher than 1280 X 800 Pix.

    Thanks for the help,

    Fun1975

    First, you must use the page to Toshiba display driver.
    The use of other drivers can lead to highest GPU temperature and cause overheating.

    But if you want to use other drivers, you can do so at you own risk.
    In order to install another driver, go to Device Manager, mark the graphics card, then press on uninstall button.
    Then the driver should be uninstalled.

    After you restart the laptop, you can try to install the new version.

    > It is also not possible to change the settings for graphic resolution higher than 1280 X 800 Pix.
    The internal screen for laptop supports 1280 x 800 high resolution. It is not possible to choose a higher value.

  • I had to change my Apple ID because of accusations of fraud but my iPhone 6s 9.2 still has the old Apple ID and will not accept old or new passwords. How can I update the iPhone with the new Apple ID 9.2 6s?

    I had to change my Apple ID due to fraudulent charges but my iPhone 6s 9.2 still has the old Apple ID and will not accept old or new passwords. How can I update the iPhone 6s 9.2 with the new Apple ID and password? I tried to perform a complete reset, but which requires the Apple ID and password that doesn't work not... pretty frustrated here.

    YYou have unlink the old iphone you as find my iphone the reset all devices on this subject from your account then plug it to your iTunes then restore a new one after that reset password that under the new phone then connect

  • I managed to see the profile of the artist in Apple's music. How can I update the profile picture?

    I managed to see the profile of the artist in Apple's music. How can I update the profile picture?

    This is a user forum. No Apple itself is allowed to answer your questions here.

    You are probably better contact Apple Support directly to get an answer to your question.

  • How can I update the gps of streets & trips

    How can I update the gps of streets & trips (not sure which version)

    Hi CP agent v-2jeen

     

    Because the question is specific to the streets and trips you contact that it can support the assistance team. I would recommend posting your query to the community of Microsoft streets & trips. Please visit the links below to find a community that will support what ask you in the right direction.

    http://social.Microsoft.com/forums/en-us/streetsandtrips/threads

    You can also check out below help links-
    http://support.Microsoft.com/ph/1058#TAB0
    http://www.Microsoft.com/streets/en-us/support-and-training.aspx

    I hope this helps.

  • How can I update the expiration date on my credit card account?

    How can I update the expiration date on my credit card account?

    How can I update the expiration date on my credit card account?

    Go to your Bank and get a new card.

  • I'm not having implemented the cd with me. How can I update the window components. by mistake I uninstalled the

    I'm not having implemented the cd with me. How can I update the window components. by mistake I uninstalled the

    Reinstall windows components, you've accidentally deleted when you have the game CD with you.

  • How can I find the WEP key for my wireless network so that I can connect to it?

    How can I find the WEP key

    Steps to find a WEP key:

    1. open a browser (the program used to access the internet). The following process worked for me when using the

    Internet Explorer, Firefox and Opera browsers, although I'm not sure it will work for other browsers (for example

    Chrome, Safari etc.).

    2 type the following in the address bar of the browser. If you use a Linksys router type in "192.168.1.1" and if

    using a type of router Belkin "192.168.2.1". The address bar is the area where the Web pages are typed. It is important

    When you enter there is NO http://www. before the numbers.

    3. If everything is is well past that should open a page which says that Linksys or Belkin.

    3. There may be the need of connection. When you use a Linksys if you don't know what are the user name and password, it may

    always be the factory settings and then enter "admin" for the username and "password" for the password. If you are using a

    Belkin router, the factory settings often come without password, click just send without having to type a password.

    4. click on one) "wireless" or b) "settings".

    5. click one) "Wireless security" or b) "wireless settings".

    6. There should be a page with a specified WEP key.

    7 writing it to the down/copy and use as you wish!

  • I had a hard drive crash and had to move all the data again. Now, I get an error saying that my Visa is not an authorized version. How can I find the product key to reactivate?

    Vista Product Code question

    I had a hard drive crash and had to move all the data again.  Now, I get an error saying that my Visa is not an authorized version.  How can I find the product key to reactivate?  I don't have the sticker on the back and the software I have does not have the code?  I bought this laptop DELL at Best Buy a little more than a year.

    Thank you.

    Hello

    This problem may occur if you make a significant hardware change. See the link provided below.

    Error message when you start Windows Vista: "your activation period has expired".

    http://support.Microsoft.com/kb/925616

    If the OS came preinstalled Dell you may need to contact Dell technical support for assistance.
    http://support.Dell.com/support/topics/global.aspx/support/win7_support/win7_portal?c=us&CS=04&l=en&s=BSD

  • How can I find the product key if the laptop was a gift?

    How can you find the product key if the laptop was a gift and you do not have a cd

    Hello

    If you are unable to retrieve the product key provided with the system then Windows communicate with the system
    Maker.

    Look at the lower/rear part computer and tape or disks that came with the unit.

    If the system is still running, you can use these to access your product key. These are not cracks, they
    only retrieve your existing key.

    One of them allows to recover your machine if possible.

    ProduKey - FREE - a small utility that displays the ProductID and the CD - Key of Microsoft Office
    (Microsoft Office 2003, Microsoft Office 2007), Windows (including Windows 7 and Windows Vista).
    Exchange Server and SQL Server installed on your computer. http://www.NirSoft.NET/utils/product_cd_key_viewer.html

    WinGuggle 1.5 product key
    http://unlockforus.blogspot.com/2008/01/WinGuggle-get-your-Windows-Vista.html

    Magic JellyBean
    http://magicaljellybean.com/KeyFinder/

    Windows product key Viewer
    http://www.rjlsoftware.com/software/utility/winproductkey/

    How do I see the key to product under Vista (and Windows 7)
    http://www.Vistax64.com/tutorials/85023-product-key-number.html

    I hope this helps.

Maybe you are looking for

  • Extra RAM to presario SR5019uk

    the SR5019uk takes PC2 4200 DDR2, I put low spec RAM inside until the memory? ATM it has 512 MB but I have two other sticks of 512 MB PC2700 DDR, I think that would only go to the speed of the PC2700, but I have a GB and a half in total so I could li

  • Table, a modified cell reference

    I'm curious to know if I am missing something, or if someone has an eligant way more to capture the last cell changed in a table... I thought that this would be an easy value change event by using either the ActiveCell > CellPosition node or the Edit

  • Ongoing the new 15-D014tu HP laptop fan noise

    Hello I received today a new HP notebook (actually a replacement for a purchased a week ago, which had a faulty NIC in it) and ran it quietly for much of the day, but after unplugging and taking in another room tonight that I can now hear the fan run

  • Lollipop 5.1.1 Messaging app contains a wizard?

    Hello Once the upgrade to lollipop 5.1.1 my Xperia Z3 comapct shows something like an assistant when I start the messaging application, that I've never seen in earlier versions. Background: because of the stagefright bug I'm very careful when it come

  • Driver printer HP Photosmart C6380 for Windows 7

    I can't scan from the HP C6380 Phtosmart to Windows 7: "scan to computer".  In fact I have not Essentials or Solution now that I upgraded from panoramas to windows 7.  Told me to remove the driver in Control Panel and install a new driver.  Help.