Can primary key be changed?

Hi all,
I found that if primary key is changed, the SQL statement generated is strange. For example, I have an object A, with primary key = 12345. In the UoW, I update the primary key to 1000. The SQL statement generated would be something like "UPDATE A SET PK = 1000 WHERE (PK = 1000)". Is it the expected behaviour of toplink?
Thanks and regards,
William.
PS: Proxy in direction is for object A. Would it tbe cause of the strange behaviour?

Primary keys cannot be changed.
Primary keys are used to maintain the identity of objects. Changing the primary key would change the identity.
If you need to change a primary key field, the best thing to do is delete the original object and insert a new object with a new primary key and other fields copied as appropriate.

Similar Messages

  • IR - if count (primary key) cannot change to count different column

    Apex 4.1.1.00.23 Windows 7 IE8 / Firefox 16
    If I add a Group By and Count to an Interactive report and choose the primary key column as the one to Count, run the report and then edit the Group By to count a different column, the result set does not change, and if I edit the Group By again it shows that the Counted column has reverted back to the primary key column.
    If I initially choose a different column I can change it and rerun the report successfully, but once I choose the primary key column it cannot be changed. This seems to happen on all applications and all browsers. Is it a bug in Apex?
    Thanks,
    Nick.

    I've tried this in 4.1.0.00.32: works normally. In 4.1.1.00.23 however i'm getting the weird behaviour: you can count on any column, but the moment you count the same column as the one grouped on you can not change the column back to another one anymore. Something which works fine in 4.1.0.00.32.

  • Another user has changed the row with primary key -Table changed externally

    Hello,
    I am facing the error: "Another user has changed the row with primary key oracle.jbo.Key[94 ]." during the delete operation.
    User case scenario:
    1. Added new row in the table.
    2. Once new row is added to the the table, another application will update few columns in the newly added row based on some logic.
    3. On the same session I am trying to delete the newly added row and getting above mentioned error.
    I have added a "Button" in the table to partialRefresh the table to check the new values of the changed columns.
    I have checked the forum and found many similar errors and tried the following but nothing helped.
    1. By setting "Auto Refresh = True" for the view object.
    Issue faced-> It worked fine but after few add and remove my db is getting to inconsistent state after which, I am not able to do any add/delete from my page.
    Error: "Too many objects match the primary key oracle.jbo.Key". I have checked this and I am not getting this error when "Auto Refresh = False" even after multiple add and remove actions.
    2. By Setting "Auto Refresh" the iterator associated with the page.
    Issue -> Did not work at all.
    Looking forward inputs from gurus.
    Thanks
    Abhijeet

    Finally I found one solution to this problem at: [ http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/|http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/]
    Simply overriding the lock() method in the entity object resolved issue. Kudos to the author.
    Code:
    public void lock() {
    try {
    super.lock();
    } catch (RowInconsistentException e) {
    refresh(REFRESH_WITH_DB_ONLY_IF_UNCHANGED | REFRESH_CONTAINEES);
    super.lock();
    But, Now my refresh button is not working as depend on the "Auto Refresh = True" to update the table.
    Can anyone tell me how can I refresh the VO of my table from the button.
    Thanks
    Abhijeet.
    P.S: I have already added the partial trigger but it is work not working as the data is cached in the VO. Removing the Cached property for the VO is creating other problems.

  • Primary key and change indicator

    So I was creating an employee and then I committed the records and then I tried to delete a record from the same table. I encountered an error like below:
    "Another user has changed the row with primary key"
    So I searched the solution of this problem, and then I read this article https://blogs.oracle.com/onesizedoesntfitall/entry/the_case_of_the_phantom
    This is the solution according to the above article:
    Alternatively you can set the Change Indicator on one of the attributes.  This will work as long as the relating column for the attribute in the database itself isn't inadvertently updated.  In turn you're possibly just masking the issue rather than solving it, because if another developer turns the Change Indicator back on the original issue will return.*
    Well, then set the Change Indicator of the EmployeeID attribute (which happens to be the primary key of the table). Now its working fine.
    But my question is: Is this okay if I am setting the Change Indicator of a primary key attribute to be True?

    >
    Sonull wrote:
    I have set the Type property of employeeID as DBSequence. So when the system creates a row, the values displayed for the employee ID is in the form of negative numbers (-1, -2, -3). Only after committing the rows does the trigger gets fired, and the next number in the sequence is generated, and the row is saved in the database.
    >
    I don't understand you? are you asking a question or provide information?
    When set the type of an attribute to DBSequence, by default Jdeveloper sets the Refresh on Insert property.
    What I want to say is that the problem is not in the EmployeeId attribute.

  • Can Primary Key values be empty?

    Hi,
    We have some custom tables created in ECC 6.
    One of the tables contains the below fields.
    <i><b>MANDT
    PERIOD
    KOSTL
    LSTAR
    AUFNR
    <u>SOURCE</u></b></i>
    POOL
    PRODUCT
    .... etc.
    Key/Initial Values check boxes are selected for fields in bold/italic above.(I mean primary key).
    But when I check the table contents, <u><i><b>SOURCE</b></i></u> column contains empty values(nothing) for some records. Is that correct?
    I think Primary key fields should contain some value in a record.
    Please advise.
    Thanks in advance.
    Han

    Have a look at table S001.  Hopefully there is data for this table in your system.  The first couple fields have initial values in my system.
    Regards,
    Rich Heilman

  • JBO-25014: Another user has changed the row with primary key oracle.jbo.Key

    Hi,
    I am developing a Fusion Web Application using Jdeveloper 11.1.2.1.0. I have a home.jspx page that has a ADF table built on efttBilling View Object. . When you click on one of the rows in the table, it will take you to detail.jspx where you can edit the row and save. When 'save' is clicked, stored procedures are executed to update/insert rows into few tables , and then go back to home.jspx where you need to see updated content for that row.
    To get down to the exact issue, updates are made to the tables on which the efttBilling View Object is built using a stored procedure. Once this is done, I am trying to requery view object to see new content. But I keep getting JBO-25014: Another user has changed the row with primary key oracle.jbo.Key error. Following are the approaches I followed to query new results:
    a. Executed Application Modules Commit Method. Created 'Commit' Action binding and tied it to homePageDef.xml. Called this binding from a view scope bean.
        BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
         OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
       if (!operationBinding.getErrors().isEmpty())
        return null;
    b. Marked 'Refresh on Insert' , 'Refresh on Update', 'Change Indicator' checkboxes for all the attributes in the entities associated with efttBilling View Object.
    c. Tried to Requery View Object. Created a refreshViewObject method in Application Module Impl.java file, exposed this method to the client interface and created a invokeMethod Action binding in home.jspx
    Code in Application Module:
      public void refresheftTransactionsforBillingAccountViewObj1View()
        System.out.println("In eftTransactionsforBillingAccountViewObj1");
      findViewObject("eftTransactionsforBillingAccountViewObj1").executeQuery();
    Code in view scope bean
            DCBindingContainer bindings =
           (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            OperationBinding operation =
            bindings.getOperationBinding("refresheftTransactionsforBillingAccountViewObj1View");
            operation.execute();
    I have searched web, ADF forums and tried methods suggested in there but no sucess.
    Could anyone please provide some insight in this issue. I have been battling with this since quite some time. I can provide you with the log file too.
    Thanks!
    Shai.

    What code does your Commit method have .. can you try using the Commit executable from the AM itself instead ?
    Also -
    Shai wrote:
    'Change Indicator' checkboxes for all the attributes in the entities associated with efttBilling View Object.
    which all attributes you set this property for . it should just be for History columns as such.
    Did you also check if this could be your scenario ?
    Decompiling ADF Binaries: Yet another reason for &quot;JBO-25014: Another user has changed the row with primary key orac…
    OR
    JBO-25014: Another user has changed the row with primary key oracle.jbo.Key
    OR
    Another user has changed the row with primary key -Table changed externally
    Message was edited by: SudiptoDesmukh

  • Primary keys and foreign keys

    Hi,
    is there a script available for changing the value of a primary key which automaticly
    detect all foreigs keys refering to this primary key and change them as well?
    William Oorschot

    I don't have the script now. but you can make a procedure of ur own.
    using a join on user_constraints, and user_cons_columns you can find out all the columns in all the tables which are referencing the particular primary key. once you have the table and the referencing columns, you can change the value of those columns with the new value.
    you'll have to call this procedure from a before row level trigger.
    HTH
    Naveen

  • Table Creation & Primary Keys

    Hi there
    I have a table with the 1st 3 fields as primary keys. I now need to change this to other fields.. But these fields are in the middle of the table. Apparently the primary keys must be the first fields in the table so I have to move the fields I need up. The problem is it will influence my XI/PI development cause Im using substrings to get the correct fields and If I change the order of the fields my interfaces will not work anymore.. I there a way to set the primary keys without changing the order of the fields?
    Thanks,
    Jan

    Hi Jan,
         I think there is no other way to do it. All the primary keys should be declared in continuation at the begining of the table. Try to change your XI/PI development according to these entries.
    Regards,
    Swapna.

  • Primary Key constraint on Views

    Hi
    Can primary key or unique key constraint can be imposed on a View created in Oracle 9i?
    Thanks in advance

    Hi
    Can primary key or unique key constraint can be
    imposed on a View created in Oracle 9i?
    Thanks in advanceNot sure whether you want to know about Materialized view or not !
    But if it is just a View then the Primary Key and Unique Key can be imposed in its underlying Table(s).
    Thanks

  • Can I have a primary key as a non-unique column

    Hi all,
    I have a table with 35 columns and only one column in a not null column. But this column data is not unique. I want to create a primary key with non-unique index, can I don it, if it is not possible is there any other way to it. Please help me with this.
    Thanks for your help.vinaykotha

    1) Do the 'Unique Column combination' check first, using this example. (Pl. Change the column name and number of columns you consider as candidate key.) The SQL as follows:-
    ;WITH CTE (ProductKey, CustomerKey, SalesTerritoryKey, DupRec)
     AS
      (SELECT ProductKey, CustomerKey, SalesTerritoryKey, ROW_NUMBER() OVER
         (PARTITION BY ProductKey, CustomerKey, SalesTerritoryKey
          ORDER BY ProductKey, CustomerKey, SalesTerritoryKey) AS DupRec
       FROM dbo.FactSales 
    SELECT *
    FROM CTE
    WHERE DupRec > 1
    2) if CTE Table returns no records, you are good to create a Composite CLUSTERED PRIMARY KEY, like:
    ALTER TABLE dbo.FactSales
    ADD CONSTRAINT PK_ProductKey_CustomerKey_SalesTerritoryKey 
    PRIMARY KEY CLUSTERED (ProductKey, CustomerKey, SalesTerritoryKey);
    If no error..bingo! if NOT, Don't worry, create a Composite Index like this:-
    3)
    CREATE NONCLUSTERED INDEX [IX_ProductKey_CustomerKey_SalesTerritoryKey] 
    ON dbo.FactSales(ProductKey, CustomerKey, SalesTerritoryKey);
    This will work still efficiently. Usually all transaction table are like that like Daily_Order table, Ship_Details table etc.
    -NC

  • How can we export the Primary key values (along with other data) from an Advantage database?

    One of our customers is moving from our application (which uses Advantage Database Server) to another application (which uses other database technology). They have asked us to help export their data, so that they can migrate it to another database system. So far, we have used the Advantage Data Architect (ARC32) "Export Table Structures as Code" functionality to generate SQL. We used the "Include existing data" option. The SQL contains the necessary code to recreate the tables and indexes. The customer's IT staff will alter the SQL statements as necessary for their new system.
    However, there is an issue with the Primary Keys in these table. The resulting INSERT statements use AutoInc as the type for the Primary Key in each Table. These INSERT statements contains "DEFAULT" for the value of each of these AutoInc fields. The customer would like to output an integer value for each of these Primary Key values in order to maintain referential integrity in their new system.
    So far, I have not found any feature of ARC32 that allows us to export the Primary Key values. We had been using an older version of ARC32, since our application does not use the latest version of ADS. I did download the latest version of ARC32 (11.10), but it does not appear to include any new functionality that would facilitate doing this sort of export.
    Can somebody tell me if there is such a feature in ARC32?
    Or, is there is another Advantage tool to facilitate what we are trying to accomplish?
    If there are no Advantage tools to provide such functionality, what else would you suggest?

    George,
      It sounds like the approach you are using is the correct one. This seems to be the cleanest solution to me especially since the customer is able to modify the generated SQL statements for their new system.
      In order to preserve the AutoInc values I would recommend altering the table and changing the field datatype from AutoInc to Integer. Then export the table as code which will export the actual values. After the tables have been created on the new system they can change the field datatype back to an AutoInc type if necessary.
    Regards,
    Chris Franz

  • How can I replicate a source table that doesn't have any primary keys?

    We have transactional replication setup in our workplace.
    In the source database, there are some tables that do not have any primary key.
    1) How can I get these tables to replicate in the current scenario?
    2) Is it possible to introduce foreign elements in a replicated instance of the database?
    Example, additional records in a table that don't exist in the source or additional tables in the database?

    1) You need to add a primary key to this table. There must be a criteria that the app uses to identify which row it wants to up date or delete. If not you might be able to add an identity column to the table and then add a primary key to it. If this is not
    possible you might want to use snapshot replication or CDC to do change tracking and then something like SSIS or service broker to move the change to the destination server.
    2) yes, but be careful. They should not modify the schema or the data of tables which are being replicated.
    looking for a book on SQL Server 2008 Administration?
    http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
    http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941

  • How to change the source type for a primary key on a form?

    Hi,
    At the time of creating a form, I had set the source type for the primary key to an existing sequence.
    Now I want to change the source to a trigger.
    Can anyone suggest how to do it?
    Thanks in advance,
    Annie

    Annie:
    Define the trigger and then delete the page process named 'Get PK'
    Varad

  • How to change primary keys of existing InfoCube.

    Greetings everyone!
    I’m trying to change the Key Fields in my reporting architecture as per our new company mandate.  I’ve been able to successfully change the primary keys for DS, DSO and InfoSource.  Can any kind soul out there please tell me how to change the primary keys on an existing InfoCube?  I will surely appreciate all the assistance I can get.  Its kinda urgent!
    Regards,
    Philips

    Hi,
    Check the possibility with Remodelling option . If it is not possible with Remodelling, then you can only change the cube deleting the Data.
    With rgds,
    Anil Kumar Sharma .P

  • Can we create an APEX Form based on Table which has no Primary Key

    Hi,
    I have a requirement.
    I need to create a FORM based on a table having no Primary Key but it is having Unique Key . I can use Unique Key as an alternate of Primary Key.
    but When I tried to create a Form, I got the following message.
    Source tables for forms and tabular forms must have a primary key
    Thanks,
    Deepak

    Deepak_J wrote:
    Hi,
    I have a requirement.
    I need to create a FORM based on a table having no Primary Key but it is having Unique Key . I can use Unique Key as an alternate of Primary Key.
    but When I tried to create a Form, I got the following message.
    Source tables for forms and tabular forms must have a primary key
    Thanks,
    DeepakGood database design will always require a PK on the tables. There are only very few and rare expetions to this rule. One would be when you have store the data only temporarily in this table, like it is often done for import/loader tables. The data is first loaded in the "import"-table, then validated and then transported to the "real" tables. In such a scenario you can ignore the primary key on purpose. Because you already have a UK on this table it can't be such a scenario.
    For most other scenarios you should always add a PK. Ask critically why there is no PK on it. Is there a reason for it or was the table designer just not doing its job well?
    Btw: A UK is identical to a PK if the column is mandatory (NOT NULL). In this case you could simply change the constraint from UK to PK.

Maybe you are looking for

  • Access to SAP Netweaver 2004s --- ECC 6.0

    Good evening.... The question is: Must I install the java engine in my sap ECC 6.0 to access via web to SAP or isn't necessary ??? I've read in the marketplace and I think isn't necessary but I need to be sure. I'll can access via web (internet explo

  • Failed to load Core DLL-Adobe Reader XI

    This is the error message I got when I downloaded and upgraded from a perfectly functional Adobe Reader 9.5 to Adobe Reader XI.  It did download in protected mode but I didn't have any problems with it last time I upgraded and downloaded in protected

  • Getting Windows SDK function returned an error. (Error code -12) while building the D-kit

    Hi,  I use LabWindows CVI 8.5 to build the D-kit in windows xp os.when i try to build the D-kit it is throwing the following error.i have attached the error log along with this post.request to provide solution to over come this issue ASAP.it is very

  • Help with difference in Create Customer UI

    Need assistance with different Create Customer UI See above Create Customer how to change to allow entry of Company Code and Sales Area data

  • Affordable graphics editing?

    Because PhotoShop has been too pricey for my blood, I've used GraphicConverter for years, although my technique has not advanced as fast as GC's capabilities have. So I have some questions for you value-oriented GC users in this value-oriented Mini f