update of a primary key column

Hello

I have a problem I want to expose you for your opinion.

In a table of the source, I have a primary key consisting of four columns (let's call them A, B, C and D).

Columns D must be updated with a different value (a Mappin with another table)

My ODI interface, I set the update keys a, B, C, but of course, it does not work because there is violation of the primary key

I thought, the first value of D in a new column (D_OLD) and use as a 4th update key.

What do you think?

Please suggest me the right way to do it

Thank you for your return

Hello

Maybe I did not understand your problem correctly, but you say that you want to update the value of col D what happens to the part b of your primary key. You cannot update the row using columns A, B and C, because they are not unique. Am I wrong? If this is the case, then how will you identify which line you want to update the value of col D for. Tell if you have 2 lines with the same value for columns A, B and C, and a different value of D so how do you know which line you want to update? If you have the answer to this question, then you should be able to update as well.

Thank you

Ajay

Tags: Business Intelligence

Similar Questions

  • 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;

  • 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

  • Diagram of all the tables list of primary key column names

    Hi people,

    I have a Scott user for example, I want to retrieve all tables primary key column names in the user Scott.

    can someone help me please.

    Thanks in advance,
    karmaya

    You can log in to SCOTT and try this

    select c.constraint_name
         , cc.table_name
         , cc.column_name
      from user_constraints c
      join user_cons_columns cc
        on c.constraint_name = cc.constraint_name
     where c.constraint_type = 'P';
    
  • A composite primary key column cannot be null

    Hi all
    It will be a silly question, but still, I would like to ask if a composite primary key column can be null?


    Thank you
    Rafi.

    Rafi,

    Why you think he would be allowed?

    SQL> drop table test purge;
    drop table test purge
               *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    SQL> create table test as select * from dba_objects;
    
    Table created.
    
    SQL> alter table test add primary key(object_id, owner);
    
    Table altered.
    
    SQL> insert into test(object_id, owner) values(null, 'aman');
    insert into test(object_id, owner) values(null, 'aman')
                                              *
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OBJECT_ID")
    
    SQL> insert into test(object_id, owner) values(1,null);
    insert into test(object_id, owner) values(1,null)
                                                *
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OWNER")
    
    SQL>
    

    HTH
    Aman...

  • Add new ID/Primary Key column with custom ID generation

    I use Hibernate as ORM to interact with Oracle.

    This issue is no longer on the side of SQL to emulate the generator ID seqHiLo

    that we use to generate the primary key for tables, the column ID i.e.

    Now I want to add a new column to the ID of an already created table, and this table has data.

    I have a procedure to add the ID column in a table:

    For example:

    ALTER table TableName add (columnName NUMBER);

    Then create the sequence

    CREATE SEQUENCE SEQ_ID

    START WITH 1

    INCREMENT BY 1

    MAXVALUE 99999999

    MINVALUE 1

    NOCYCLE;

    and after that he use the UPDATE statement to insert some values into the column like this

    UPDATE tableName SET columnName is seq_test_id. NEXTVAL

    Here I intend to use hibernate_sequence, to be in harmony with the hibernation of generation mode the ID's

    The question is:

    UPDATE tableName SET columnName = hibernate_sequence. NEXTVAL, generates the ID in the order.

    However, I need identifiers according to the algorithm of seqHiLo.

    Is there a way to do this in pure SQL?

    In short, can we have a personalized way to generate IDS to use in the new column, rather than a sequential,

    as stated above?

    If you update every row of a session, it won't make any difference if you select from a sequence and use this value immediately (as in your example) or if you go through the algorithm of HiLo: be it you will end up with sequentially numbered lines without leaving space. Then after the update block of existing lines, you will need to create the sequence to be used by your Hibernate application with an initial value of your current value divided by the low value.

    If you really want to implement the algorithm of HiLo for the bulk loading, you can of course do so. But it is not necessary: the effect will be the same.

  • How to use a Select list on a second primary key column in a tabular presentation?

    Hello

    I created a tabular presentation located on the details page of the user (form), that allows to manage roles for this user.

    The shape of table contains 3 elements:
    -> a checkbox
    -> user (PK) column is hidden, and its default value is generated by a function pl/sql (to submit the time), which refers to the element to username.
    -> the role of the column is displayed as a named select list LOV: add you a line, choose a role, submit, etc..

    But my ROLES table (not created by me...) contains 2 columns: USER and GRANTED_ROLE.
    The USER is the primary key, but a user can have multiple roles (= one line per role).
    GRANTED_ROLE is the second primary key, so that we can differentiate between one line of another.

    At the moment my tabular form has only one primary key (USER), so the GRANTED_ROLE can display as a list select.
    But, for this reason, in my opinion, remove the button do not work: all the lines of the user have the same key, so when I select a few lines to remove these, all lines in the form of tables are deleted.

    I don't know how my button Delete could recognize the subkey to remove only selected rows...
    Or maybe I should use a different type of region?

    Thanks for your help!
    Fanny

    In the process of ApplyMRD, try to specify the 'secondary key' column in the section "Source: Multi line Update and Delete"to the second column key in tabular form.»

    I have not tested this with your situation, but worth it.

  • Updating related Records primary key and FK dependencies

    (1) how can I found the name of all the tables that use my primary key as a foreign key? The primary key is of type varchar and used in many other paintings. Now PK records must be changed by the customer's request, so it will affect obviously all of my dependent tables.
    (2) which corresponds to the PL/SQL script more efficient to perform this procedure?
    All suggestions will be useful.

    To test, I think I want a list of all tables in followed by a list of all affected records. This report must show registration PK & all records in dependence requiring an update. Is this reasonable?

    user10998542 wrote:
    (1) how can I found the name of all the tables that use my primary key as a foreign key? The primary key is a varchar and used in many other paintings. Now PK records must be changed by the customer's request, so it will affect obviously all of my dependent tables.

    Discover the view USER_CONSTRAINTS. You could do something like this:

    SELECT     UC.OWNER
    ,     UC.TABLE_NAME
    ,     UC.R_OWNER
    ,     RUC.TABLE_NAME
    ,     UC.R_CONSTRAINT_NAME
    ,     RUC.CONSTRAINT_TYPE
    FROM     USER_CONSTRAINTS UC
    ,     USER_CONSTRAINTS RUC
    WHERE     UC.R_OWNER          = RUC.OWNER
    AND     UC.R_CONSTRAINT_NAME     = RUC.CONSTRAINT_NAME
    AND     UC.CONSTRAINT_TYPE     = 'R'
    

    If you need names of columns, you can use the USER_CONS_COLUMNS view also.

    (2) which corresponds to the PL/SQL script more efficient to perform this procedure?
    All suggestions will be useful.

    [Tom Kyte: package Cascade | http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteupdatecascade.html]

  • addition of populated table's primary key column

    Hi all


    I am trying to add a column to a table that is already filled. The column to be added must be the primary key.
    As expected, oracle jumped to the top of the error (ORA-01758) of a column NOT NULL cannot be added, unless the table is empty.

    A possible way is to create a new temp table and then transfer all current data... rename the temporary table later.

    Is there another way to accomplish this?

    Thank you

    Hello

    As error suggested you cannot add a constraint not null on the new column to the table that is already filled. What else you can do next to you, you have a fairly simple and fast to create a temporary table and moving data?
    You can add the new column but null, update the column with values and alter the table of marking column as not null. But your idea of empty temporary table is simple and fast.

    CREATE TABLE my_objects
    AS
       SELECT 'my_new_column' my_new, owner
       FROM all_objects
       WHERE ROWNUM < 1;
    
    _Not Null_
    ALTER TABLE MY_OBJECTS
    MODIFY(MY_NEW  NOT NULL);
    
    _Primary key_
    ALTER TABLE MY_OBJECTS
     ADD CONSTRAINT MY_OBJECTS_PK
     PRIMARY KEY
     (MY_NEW);
    

    Concerning

  • By specifying the Composite primary key (columns 4 and 5)

    Hi all

    I am new to Oracle Apex,

    I have a few paintings with a composite primary key (4 or 5 columns)... When I try to create a primary key constraint, it gives me only 3 columns!

    Any help please in how can I solve this problem?

    Thanks in advance

    You are probably using the workshop for this sql Object Explorer

    which seems to be limited to 4 columns on APEX 4.2.3

    best thing to do is to create manually using the sql commands in sql workshop, here's an example:

    {code}

    CREATE UNIQUE INDEX myui ON JC_ACCOUNT

    (TITLE_ID, FAMILY_NAME GIVEN_NAME, GENDER_ID, TELEPHONE_NUMBER)

    /

    {code}

    I hope this helps you

    KR

    Martin

  • Change of primary key on the Table clears the other columns

    Preliminary info/Installation
    JDeveloper 11 g 11.1.1.6.0
    We have a table (object view or entity) that has 8 columns. The primary key is composed of 4 1 columns.
    The table is displayed in a page fragment.
    2 of the 4 non-primary key columns are LOV.
    All the 8 columns are needed.
    The table is editable including 2 of primary key columns.

    Question
    Assume that the table displays the 3 lines. If we change a rank 1 non-primary key column and a primary key in row 2 column, everything works well when we are committed to the database
    If, however, we first change a primary key column, then a primary key on a different line column, then the column/row primary key that changed us first, gets annihilated and the other columns LOV on this same line. The 2 columns that are not LOV keep data as it should. We then get a validation error because the required data are not present. All this happens before we try all commit to the database. If debug us and look the iterator, it has the old data in this document, before and after any performance on the binding.
    If we look at and update the data via the App Module, everything works well. We have tried to update the view, etc. through valueChangeListener also with no luck.

    If you change the primary key value, it should not be the primary key.

    This is true in the design of database relational regardless of how access you the data. In addition, EO don't like if you change the primary key value.

    Have you considered adding a surrogate key (use a sequence) and make your PK course a unique key?

    John

  • Update primary key with waterfall

    Lets say I have 10 tables that have a foreign key defined, that everything points to a single table primary key.
    Now, I want to update the value of the primary key to another value, and I want all 10 tables to get this new value in their columns FK.
    Also, note also that some of these 10 tables can have this FK-value that is updated to PK-table.
    I can do this task with a good script?

    I would like to somehow in this way:
    Update PkTable set
    Pkcol=NewAvailableValue
    CASCADE;
    Right now I use the following approach:
    1. from table "user_constraints" find FK constraints binded to the primary change being key to find the list of tables.
    2 query each table if it has the PK value in their columns-FK, if has, then update the value allowed another PK-value.
    3. Update PK-value of primary key column of the table to the new value.
    4 validation.

    Maybe this will be useful: Tom Kyte: UPDATE CASCADE PACKAGE

  • No column primary key not defined. error

    Hi all

    First of all, thanks to DWFAQ for advice a tutorials.

    Secondly, I built a contact form the wizard of registration form of update to MEASUREMENT - http://dwfaq.info/home.php?id=4

    I hit a problem, when you run the form I get the following error:

    Error:
    Internal error.
    Details of Developer:
    tNG_update.prepareSQL:
    No primary key column is defined. (UPD_NO_PK_SET)
    tNG backtrace - REVIEWS

    * tNG_update.executeTransaction
    o STARTER. Trigger_Default_Starter
    o tNG_update.doTransaction
    + BEFORE. Trigger_Default_saveData
    # tNG_update.saveData
    + BEFORE. Trigger_Default_FormValidation
    + tNG_update.prepareSQL*
    o tNG_update.getRecordset
    o tNG_update.getFakeRsArr
    o tNG_update.getLocalRecordset
    o tNG_update.getFakeRecordset

    Could someone please help - I'm so closely that it made wrong ;-)

    Thank you

    NJ

    Heya,

    I received your email and took a look at your script. It seems that the question was in the transaction of PrimaryKey. I sent the file to you with some modifications, where he says:

    $upd_contact-> setPrimaryKey ("id", "NUMERIC_TYPE", "GET", "id");

    I changed to

    $upd_contact-> setPrimaryKey ("id", "NUMERIC_TYPE", "VALUE", "id");

    There are other things that I've cleaned up a bit, but I think that's what was causing your error.

    Hope that helps!

Maybe you are looking for

  • Country codes?

    We lived in Singapore for two years and I bought a Time Capsule while we were there. Now, back in the States, I have no option for the USA under the country code that affects the performance of the network? What is indicative in any way? I have to bu

  • Satellite T130-11U - webcam showing an image rather than broadcast

    Hello Just got this new laptop Satellite T130-11U, and I can't use webcam.I tried to set up with the sidebar of toshiba and also with live messenger or Skype with no result.The webcam is always a picture of a beautiful coast with a laguna of broadcas

  • HP Photosmart 7520 will be black printing ink ot

    My photosmart 7520 quit printing black in the middle of a print job.   All cartridges except black needed changed.  I did this and no black printing.  Changed the black cartridge just in case.  No black printing.  I cleaned the connections of the ele

  • Vectorize an image using Labview

    Hello world! So, I work with a 3D cutting machine (Roland MDX - 15) and I'm supposed to design a program that can load images and burn them on a piece of wood using Roland MDX - 15. What I've done, is to create a program where you can draw a picture

  • Difficulties of Smartphones from blackBerry to install Blackberry Desktop Software

    I just bought a new Blackberry Curve 8320. And will have several difficulties with it I will list separately. First of all. I tried to install the Blackberry v4.2.2 CD user tools, and it never ends install, to the point that I have to do an end task.