Modify a primary key constraint

Hi,
I'm starting with oracle, and I have two doubts that can't handle after searching on the internet.
1º It's possible to make an ALTER TABLE of a CONSTRAINT DEFAULT?. Maybe you think that the question should be in another way like this: Does oracle database take the default condition as a constraint?. As long as I know, doesn't do that.
2º It's possible, with an ALTER TABLE, to MODIFY a CONSTRAINT of a PRIMARY KEY, to add another more field?
I've been searching on the internet, but I didn't find a clear answer. I'm using oracle 10g express edition.
Thank you very much.
P.D.:Sorry for my english it's not very good.

#2 - You can not 'add a column to the primary-key constraint of a table' with a single ALTER, but you can drop and re-create the primary key constraint (including the additional column).
13:25:26> create table t1 (a number primary key, b number, c number );
Table created.
Elapsed: 00:00:00.09
13:25:46> alter table t1 drop primary key;
Table altered.
Elapsed: 00:00:00.06
13:25:47> alter table t1 add primary key (a,b);
Table altered.
Elapsed: 00:00:00.09But you will not be able to drop the primary key of an index-organized table.
13:25:47> create table t2 (a number primary key, b number, c number ) organization index;
Table created.
Elapsed: 00:00:00.03
13:25:59> alter table t2 drop primary key;
alter table t2 drop primary key
ERROR at line 1:
ORA-25188: cannot drop/disable/defer the primary key constraint for
index-organized tables or sorted hash cluster
Elapsed: 00:00:00.00
13:25:59> #1 - I'm not sure I understand your question , but you can alter a table's column to have a default. This is not a 'constraint', but a default. It only has effect when you perform an insert which does not include that column.
13:31:23> alter table t1 modify (c default 3.14);
Table altered.
Elapsed: 00:00:00.04
13:31:24> insert into t1 (a,b,c) values (1,2,3);
1 row created.
Elapsed: 00:00:00.01
13:31:24> insert into t1 (a,b,c) values (4,5,NULL);
1 row created.
Elapsed: 00:00:00.00
13:31:24> insert into t1 (a,b) values(6,7);
1 row created.
Elapsed: 00:00:00.01
13:31:24> select * from t1;
         A          B          C
         1          2          3
         4          5
         6          7       3.14
3 rows selected.
Elapsed: 00:00:00.18

Similar Messages

  • SQL Server - primary key constraint modify

    Hi,
    I have a table with many records. I wanted to modify the primary key constraint. The only way to alter the primary key constraint is to drop and create again. Please let me if it is right.
    Can we create primary key constraint with NoCheck. Since we have lots of records in our table, creating primary key constraint takes more time because it is checking the existing data. Please provide your comments.
    Thanks.

    >>I have a table with many records. I wanted to modify the primary key constraint. The only way to alter the primary key constraint is to drop and create again. Please let me if it is right.
    http://technet.microsoft.com/en-us/library/ms181043(v=sql.105).aspx
    Note
    To modify a PRIMARY KEY constraint, you must first delete the existing PRIMARY KEY constraint and then re-create it with the new definition.
    >>Can we create primary key constraint with NoCheck. Since we have lots of records in our table, creating primary key constraint takes more time because it is checking the existing data. Please provide your comments.
    http://msdn.microsoft.com/en-IN/library/ms188066.aspx
    When FOREIGN KEY or CHECK constraints are added, all existing data is verified for constraint violations unless the WITH
    NOCHECK option is specified. If any violations occur, ALTER TABLE fails and an error is returned. When a new PRIMARY KEY or UNIQUE constraint is added to an existing column, the data in the column or columns must be unique. If duplicate values are found, ALTER
    TABLE fails. The WITH NOCHECK option has no effect when PRIMARY KEY or UNIQUE constraints are added.
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Modifying column adding primary key constraint

    how can we alter a table and modify a column and add a primary key constraint to it??

    987018 wrote:
    can't we add a primary key constraint using the modify command?If the column already exists, and ther is no existing primary key, then
    SQL> create table t (id number, descr varchar2(10));
    Table created.
    SQL> alter table t modify (id not null primary key);
    Table altered.If the column does not yet exist and ther is no primary key then:
    SQL> create table t1 (descr varchar2(10));
    Table created.
    SQL> alter table t1 add (id number not null primary key);
    Table altered.John

  • SSIS - "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object ' tablename '. The duplicate key value is 1234 . Though there are no duplicate records.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.
    I suspect you are trying to insert modified records instead of updating.

  • Violation of PRIMARY KEY constraint . Cannot insert duplicate key in object

    hi i am using SQL Server, when i try to insert data from my jsp page it is inserting the data double time and when i try to submit for second time it is showing the following error.
    Violation of PRIMARY KEY constraint 'PK_EMPLOYEE'. Cannot insert duplicate key in object 'EMPLOYEE'.
    I didnt set identity for primary key. If i try to set identity to true then it is allowing data to submit only if i uncheck my primary key column in cached row set. And if i uncheck that primary key element then i can not retrieve the data by edit button. So how to solve this problem.
    Please any help would be appreciated.
    Thank You in Advance.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.
    I suspect you are trying to insert modified records instead of updating.

  • Altering Primary Key constraint on a table i Oracle 10G

    Hi All,
    Can anyone tell me how to alter a primary key constraint on any table. My concern is that, suppose i have a table called 'Employee' where only 'EmployeeName' is added as a primary ket constaint. Now i want to alter this P.K. constarint to add 'EmployeeName' and 'DateOfBirth' as a primary key. Can anyone suggest me how can i achieve that? Any help will be highly appreciated.

    hi,
    you need to drop the constraint and recreate it.
    SQL> conn scott/tiger@alpspso
    Connected.
    SQL> create table test (id number constraint id_pk primary key,name varchar(30));
    create table test (id number constraint id_pk primary key,name varchar(30))
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    SQL> create table test_table (id number constraint id_pk primary key,name varchar(30))
    Table created.
    SQL> alter table test_table modify constraint id_pk primary key(id,name);
    alter table test_table modify constraint id_pk primary key(id,name)
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> alter table test_table modify constraint id_pk(id,name);
    alter table test_table modify constraint id_pk(id,name)
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> alter table test_table modify primary key(id,name);
    alter table test_table modify primary key(id,name)
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> alter table drop constraint id_pk;
    alter table drop constraint id_pk
    ERROR at line 1:
    ORA-00903: invalid table name
    SQL> alter table test_table drop constraint id_pk;
    Table altered.
    SQL> alter table test_table add constraint id_pk primary_key(id,name);
    alter table test_table add constraint id_pk primary_key(id,name)
    ERROR at line 1:
    ORA-00902: invalid datatype
    SQL> alter table test_table add constraint id_pk primary key(id,name);
    Table altered.
    Regards.
    Navneet

  • Unusual Primary Key Constraint violation

    When using Apex collections from time to time this unique constraint error happens.
    ORA-00001: unique constraint (FLOWS_030000.WWV_FLOW_COLLECTIONS_UK) violated
    Now, I can't figure out why this constraint would be happening as we check for the existence of a collection before trying to create one, and the constraint relies on a number of values which we can't modify.
    All of our collection operations are done using the following APEX_COLLECTION calls
    COLLECTION_MEMBER_COUNT
    COLLECTION_EXISTS
    CREATE_OR_TRUNCATE_COLLECTION
    ADD_MEMBER
    DELETE_MEMBERS
    As I don't modify any data inside of the collections using any methods other than these above API calls I'm a bit confused.
    It's almost impossible for me to reproduce the error as it happens very rarely, in addition, most of the time performing the same action again after the constraint error has happened will succeed.
    Any ideas what I might be doing that could cause this?
    Thanks in advance,
    Joe

    I'm not sure if this will help but here's some more info:
    1. The constraint being violated is not a primary key constraint but a unique constraint as defined by:alter table wwv_flow_collections$
        add constraint wwv_flow_collections_uk
        unique(session_id, user_id, flow_id, collection_name, security_group_id)
    /2. The CREATE_OR_TRUNCATE_COLLECTION procedure first checks for the existence of a collection with those 5 keys. If found, it does:    delete wwv_flow_collections$ where id = <the id of the existing collection>;This delete cascades to rows in wwv_flow_collection_members$.
    Then, whether the "truncate" occurred or not it does this:    insert into wwv_flow_collections$( collection_name ) values( upper(p_collection_name));3. The TRUNCATE_COLLECTION procedure requires that the named collection exists, fetches its ID and then:delete wwv_flow_collection_members$ m where m.collection_id = <the id of the existing collection>;4.Of the two scenarios Joe showed us, the first one creates the failure condition (assuming two concurrent sessions) by allowing an insert to be performed, i.e., the "create collection" action. Even if the first inserter takes a while to commit, the second one will wait on a lock until the first inserter commits, then it will attempt an insert and raise the UK violation. In the second scenario, nobody ever inserts; only deletes from collections_members$ are issued (assuming the create_collection procedure is never called).
    Scott
    P.S. My head hasn't hurt this bad since Vikas's background job puzzler (Re: Background jobs

  • Create a materized view without primary key constraint on the base table?

    Hi
    I tried to create a materized view but I got this error:
    SQL> CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
    START WITH
    to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
    NEXT
    sysdate + 1
    AS
    select * from TABLE1@remote_db
    SQL> /
    CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
    ERROR at line 1:
    ORA-12014: table 'TABLE1' does not contain a primary key constraint.
    TABLE1 in remote_db doesn't have a primary key constraint. Is there anyway that I can create a materized view on a base table which doesn't have a primary key constraint?
    Thanks
    Liz

    Hi,
    Thanks for your helpful info. I created a materialized view in the source db with rowid:
    SQL> CREATE MATERIALIZED VIEW log on TABLE1 with rowid;
    Materialized view log created.
    Then I created a MV on the target DB:
    CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
    REFRESH FAST
    with rowid
    START WITH
    to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
    NEXT
    sysdate + 1
    AS
    select * from TABLE1@remote_db
    SQL> /
    CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
    ERROR at line 1:
    ORA-12018: following error encountered during code generation for
    "my_schema"."TABLE1_MV"
    ORA-00942: table or view does not exist
    TABLE1 exists in remote_db:
    SQL> select count(*) from TABLE1@remote_db;
    COUNT(*)
    9034459
    Any clue what is wrong?
    Thanks
    Liz

  • Materialized View - does not contain a primary key constraint

    I am trying to create materialized view. I gone through the MV wizard creation. Added 2 columns (foo_column, foo_pk) of the table and have a simple select statement (Select foo_column from foo_dim). Also created a primary key contrainst and refencing the primary key (FOO_PK) of the dimension.
    I am getting the following error:
    ORA-12014: table 'FOO_DIM' does not contain a primary key constraint

    It was solved. The table that I am querying has to have a primary key defined before creating a materialized view.

  • Primary key constraint firing when there's no need

    Hi All,
    I've got a very weird problem.
    I've written a PL/SQL procedure to insert addresses into a tabel. The adresses are assigned an unique number by means of a sequence. This unique number is the primary key of the table and has to be unique.
    The following thing occurs: The primary key constraint fires whenever i try to insert a record and i can't figure out why.
    I use the following code
    PROCEDURE mk_adr(klant NUMBER, receiver NUMBER) IS
    oidtje NUMBER DEFAULT 0;
    BEGIN
    BEGIN
    SELECT lea_adr_seq.NEXTVAL INTO oidtje
    FROM dual
    INSERT INTO lea_adr (
    oid, object, streetname,
    housenumber, housealpha, ponumber,
    postcode, cityname, locationdesc,
    province, kind, country_id,
    relation_id, offerrec_id,
    h_trans_van,
    h_geldig_van,
    h_gebruiker
    SELECT oidtje, oidtje, streetname,
    housenumber, housealpha, ponumber,
    postcode, cityname, locationdesc,
    province, kind, country_id,
    null, receiver,
    To_Date('01-01-2000'),
    To_Date('01-01-2000'),
    'conv'
    FROM lea_adr
    WHERE relation_id = klant
    EXCEPTION
    WHEN Others THEN
    conv_algemeen.debugMessage('mk_adr :: '||SQLERRM);
    END;
    END;
    as you can see the very first thing i'm doing is selecting a new unique number into oidtje from the sequence which provides the numbers. Then i use it to insert the record. The insert fails with the primary key constraint firing saying that oid is not filled with an unique number.
    When i do "select max(oid) from lea_adr;" I get a number lower than the number the i get when doing "select lea_adr_seq.nextval from dual;"
    So am i overseeing something or is something very obvious going wrong ?
    Patrick

    Write your procedure like the following and it will work.
    PROCEDURE mk_adr(klant NUMBER, receiver NUMBER) IS
    BEGIN
    INSERT INTO lea_adr (
    oid, object, streetname,
    housenumber, housealpha, ponumber,
    postcode, cityname, locationdesc,
    province, kind, country_id,
    relation_id, offerrec_id,
    h_trans_van,
    h_geldig_van,
    h_gebruiker
    SELECT lea_adr_seq.NEXTVAL, lea_adr_seq.NEXTVAL, streetname,
    housenumber, housealpha, ponumber,
    postcode, cityname, locationdesc,
    province, kind, country_id,
    null, receiver,
    To_Date('01-01-2000'),
    To_Date('01-01-2000'),
    'conv'
    FROM lea_adr
    WHERE relation_id = klant
    EXCEPTION
    WHEN Others THEN
    conv_algemeen.debugMessage('mk_adr :: '||SQLERRM);
    END;
    Using the lea_adr_seq.NEXTVAL more then once in the SAME select will return the same value for both calls.
    SQL> create sequence test
    2 ;
    Sequence created.
    SQL> select test.nextval,test.nextval from dual;
    NEXTVAL NEXTVAL
    1 1
    SQL>

  • Unable to enforce Primary Key constraint with my code

    Hi Guys
    I have a table that contains 2 columns: code and description (defined as not null). I am using oracle forms 10g, if I inset a new row both the columns: code and description should have data e.g. code: 001 and description: Main Store...
    So on forms I have an on-update trigger on block level that handles the error messages but if the user has to update the description this trigger blocks him because the value for the code i.e. 001 is already on the database but if I remove the piece of code (the first IF block on my code together with a cursor and the entire declaration section)then the primary key constraint is violated: the code is as follows:
    declare
    v_store_code store_types.code%type;
    cursor store_codes is
    select a.code
    from store_types a
    where a.code = :b1.code;
    begin
    open store_codes;
    fetch store_codes into v_store_code;
    if ( store_codes%found ) then
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    close store_codes;
    raise form_trigger_failure;
    end if;
    close store_codes;
    if :b1.code is not null and :b1.description is null then
         message('If the Store Code has been captured, then the Store Description must be captured!');
         message('If the Store Code has been captured, then the Store Description must be captured!');
    raise form_trigger_failure;
    end if;
    if :b1.description is not null and :b1.code is null then
         message('If the Store Description has been captured, then the Store code must be captured!');
         message('If the Store Description has been captured, then the Store code must be captured!');
         raise form_trigger_failure;
    end if;
    exception
              when others then
                   message(sqlerrm);
                   raise form_trigger_failure;
    end;
    My main intention here is: the user should be able to update the description field and save the changes without violating primary key on the column: code ...... please help me guys...

    ICM
    Sir as far I could understand , your problem is that your wanna allow the end users to update the Store_description , and Store_code..
    So on forms I have an on-update trigger on block level that handles the error messages but if the user has to update the description this trigger blocks him because the value for the code i.e. 001 is already on the databaseif it's right then why don't you have unique key constraints Store_description?
    alter the tables and apply unique key constraint...
    and no need to write this code
    f :b1.code is not null and :b1.description is null then
    message('If the Store Code has been captured, then the Store Description must be captured!');
    message('If the Store Code has been captured, then the Store Description must be captured!');
    raise form_trigger_failure;
    end if;because as you mentioned
    code and description (defined as not null)if they are already under not null constraints then no need to handle this in coding..
    he/she must be able to change the description and save the changes without affecting the code i.e.:Sir I think updation in records can only be performed when the forms is in query mode e.g execute query, have all/desired records and then make changes
    (1)description is in unique key constraint it can't be duplicated ..
    (2)code is PK it can never be duplicated...
    for this I would suggest you to have a update button on forms , when-button-pressed trigger sets property of block (update_allowed, property_true);
    and check the code of unique key violation code from oracle form's help , when that error code raise up you can show those message
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');
    Message('The Store Code you have entered already exists on the Store_Types table, please enter another code!');I hope it could do something for you
    thanks
    regards:
    usman noshahi

  • IDOC to MSsql,  error in mapping(Violation of PRIMARY KEY constraint)

    Hi All,
    I'm working with MATMAS IDOC  to MSSql. My SQL structure is of 8 tables(multiple statements) with primary key. In mapping i have used UPDATE_INSERT in action field for all the tables but still im getting "Violation of PRIMARY KEY constraint" for the last table structure. first 7 tables are single occurances but the 8th structure data is coming multple times from IDOC(E1MARMM).
    my 8th table structure is :
    STATEMENT8                                IDOC(MAPPED)
    TABLE8
    ACTION                                      UPDATE_INSERT
    TABLE                                           TABLENAME
    ACCESS     0 to Unbounded            MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Numerator_For_Conversion_To_BaseUOM
    Display_UOM
    Denominator_for_conversion_To_baseUOM
    KEY           0 to Unbounded                 MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Display_UOM
    in test tab its fine and fetching number of times according to MARMM segments  but in END to END testing its triggering an error stating that
    ""Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'MM_EAN' (structure 'STATEMENT8'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_MM_EAN'. Cannot insert duplicate key in object 'dbo.MM_EAN'.  ""
    Plz help me regarding this..

    Hi team,
    How resolve the below error 
    Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
    Thanks,
    Ram
    RAM
    There can be two reasons
    1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
    for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
    2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
    those records which doesnt already exist in the source
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Exception from HRESULT: 0x80131904 and Violation of PRIMARY KEY constraint 'AllUserDataJunctions_PK' on item.update

    HI,
    We have done following changes to Production environment.
    1. Migrated Application from 2007 to 2010
    2. Done User Domain Migration user MoveSP-User commmand
    3. Then we Run following command to block users from another domain.
    Set-SPSite -Identity 'SiteName' -UserAccountDirectoryPath "DC=xxx,DC=xxx,DC=xxx"
    After All above changes, application were working fine without a single bug. all Operation are working fine. Then suddenly from 2 days below error coming in ULS log.
    This error is thrown on item.update();
    Unknown SPRequest error occurred. More information: 0x80131904
    System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'AllUserDataJunctions_PK'. Cannot insert duplicate key in object 'dbo.AllUserDataJunctions'.  The statement has been terminated.     at System.Data.SqlClient.SqlConnection.OnError(SqlException
    exception, Boolean breakConnection)     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)     at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler,
    SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)     at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()     at System.Data.SqlClient.SqlDataReader.get_MetaData()    
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBeh...
    avior, String resetOptionsString)     at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
    method)     at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)     at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)     at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand
    command, CommandBehavior behavior, SqlQueryData ...
    ...monitoringData, Boolean retryForDeadLock)
    at Microsoft.SharePoint.SPSqlClient.ExecuteQueryInternal(Boolean retryfordeadlock)     at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean retryfordeadlock)     at Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String
    bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames,
    Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback,
    ISP2DSafeArrayWriter pUniqueFieldCallback)     at Microsoft...
    ....SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId,
    String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback,
    ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)     at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration,
    Boolean bPublish, Boolean bCheckOut, Boolean bCheckin,...
    SqlError: 'Violation of PRIMARY KEY constraint 'AllUserDataJunctions_PK'. Cannot insert duplicate key in object 'dbo.AllUserDataJunctions'.'    Source: '.Net SqlClient Data Provider' Number: 2627 State: 1 Class: 14 Procedure: 'proc_CreateItemJunctionsVersion'
    LineNumber: 9 Server: 'xxxxxxxxx\xxxxx' a035fb89-0a86-4817-b531-f20a537a002a
    SqlError: 'The statement has been terminated.'    Source: '.Net SqlClient Data Provider' Number: 3621 State: 0 Class: 0 Procedure: 'proc_CreateItemJunctionsVersion' LineNumber: 9 Server: 'xxxxxxxx\xxxxxxx' a035fb89-0a86-4817-b531-f20a537a002a
    Please help!!!
    I am unable to find any solution.
    Regards,
    Yogesh Ghare
    EDIT - Just adding some extra points that come from observation .
    1. This Error comes when following scenario is true
    First Attempt: User udated item in List "Issue Tracking" from Datasheet view
    Second Attempt: User udate the same item in list from "Sharepoint UI or Custom aspx form".. After clickin on Save button this erro comes up.
    Third Attempt: If after error user updates the same itme from UI the the data get saved
    OR
    Third Attempt : If after error user updates the same itme from datasheet view User get Unresolve data confilct again and again.
    Above Scenario is true only for Existing items in lists. For Newly added Items this is not producible(erroe not generated).One of the ovbservation is that All the items which are having issue are migrated from 2007 to 2010

    Hello,
    I have the exact same issue. SharePoint List which is causing this issue has got around 140 fields (All kinds of field types).
    Do this happen only if there is a migration from one version to other?
    This List is created using custom code - List Instance and not using Out of box SharePoint.
    Please let me know if recreating the list (using OOB) or any other fix will resolve this issue.
    Below is the ULS log:
    Unknown SPRequest error occurred. More information: 0x80131904
    System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80131904  
     at Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion,
    Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties,
    Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)   
     at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion,
    Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin,
    Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)
    System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'AllUserDataJunctions_PK'. Cannot insert duplicate key in object 'dbo.AllUserDataJunctions'.
    The duplicate key value is (21b5edcc-6e2d-421f-ad08-5a9e275add8a, 0x, 0, 10724c04-dcbb-4f02-af40-e19a694d015c, a558cc06-6f8a-408d-a1f6-f4b712d68881, 4096, 1, 4e405c39-8677-4ba0-8901-2ca4fa273461, 0).  The statement has been terminated.      at
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)      at System.Data.SqlClient.TdsParser.Run(RunBehavior
    runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)      at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()      at System.Data.SqlClient.SqlDataReader.get_MetaData()
         at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)      at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior
    runBehavior, Boolean returnStream, Boolean async)      at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)      at
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)      at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)  
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)      at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock)
    at Microsoft.SharePoint.SPSqlClient.ExecuteQueryInternal(Boolean retryfordeadlock)    
     at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean retryfordeadlock)    
     at Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32&
    plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish,
    String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)    
     at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID,
    String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish,
    String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)    
     at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32&
    ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)    
     at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents,
    String filename, Boolean bPreserveItemUIVersion)    
     at Microsoft.SharePoint.SPListItem.Update()    
     at BV.PEL.BL.Common.PublishProject(SPListItem sourceItem, Boolean isFromPublish, SPWeb web, SPSite systemSite, SPFieldUserValueCollection adminGroup, String strComments)    
     at BV.PEL.Portal.WebParts.OneBVProjectInformation.OneBVProjectInformationUserControl.buttonApprove_Click(Object sender, EventArgs e)    
     at System.Web.UI.WebControls.Button.OnClick(EventArgs e)    
     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)    
     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)    
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)    
     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)    
     at System.Web.UI.Page.ProcessRequest()    
     at System.Web.UI.Page.ProcessRequest(HttpContext context)    
     at ASP.BLANKWEBPARTPAGE_ASPX_1653093133.ProcessRequest(HttpContext context)    
     at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context)    
     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)    
     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)    
     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)    
     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)    
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)    
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)    
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)    
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

  • [SQL Server]Violation of PRIMARY KEY constraint 'DeploymentSummary_PK'. Cannot insert duplicate key in object 'dbo.DeploymentSummary'. The duplicate key value is

    I have migrated my SCCm 2007 environment to SCCM 2012 SP1 CU4.
    I noticed in the System Status\Component Status\SMS_STATE_SYSTEM a lot of errors like the one below:
    Microsoft SQL Server reported SQL message 2627, severity 14: [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'DeploymentSummary_PK'. Cannot insert duplicate key in object 'dbo.DeploymentSummary'. The duplicate key value is (1, 0, S0220438, 0). : spUpdateClassi
    Please refer to your Configuration Manager documentation, SQL Server documentation, or the Microsoft Knowledge Base for further troubleshooting information.
    When looking up the deployment ID and recreate the Deployment the problem is solved. But I have 700 packages and don't want to manually do this action on all packages. I think it is related to the migration i did and something went wrong there :-(
    Besides it will retriggers the deployment to the clients which is also not preferred.
    Is there another way to solve this by e.e.g do something directly in the SQL database tables ?

    Hi,
    It is not supported by Microsoft that do something directly in SQL database.
    If you want to do that, you could make a call to CSS.
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Violation of PRIMARY KEY constraint in JDBC receiver

    Hi Experts !
    I am configuring a JDBC Receiver. I need to insert the records and if the same record is coming again i need to update the records in my database.So I have used action "UPDATE_INSERT". But now I am getting the error,
    "Violation of PRIMARY KEY constraint-Cannot insert duplicate key in object " .. Pls help me out !!!  It is very urgent!!
    Thanks,
    Laawanya

    Lawanya,
    It seems that you are trying to update the primary key itself..
    One thing is sure The error is related to data....
    Do this at JDBC receiver Communication channel :
    Under advanced option : use parameter "logSQLParameter" and use value "TRUE"...by this way you will be able to see the values passing through JDBC receiver .
    And then check whether the same value exist in Table or not...
    Feel free to ping for further clarification..
    Regards,

Maybe you are looking for

  • How many macs can I install Lion on using the same Apple ID?

    What's the limitation? I have two Macs I would like to upgrade to Lion. I know Lion is cheap but it'd be nice to just pay one license for my two MBP's.

  • Using DVD made from VHS tape (sound only) - won't load

    A few years ago I transferred my classical music collection from reel-to-reel tape and LPs to VHS tapes. These worked very well in a VCR. Now I tried to load the contents of these DVDs insto the IPOD via ITUNES. They were not recognized, however. The

  • Idoc sent with status 03 but not arrive to destination

    Hi experts, I am working on idoc scenario on ECC6.0.I am pushing the idoc from R/3 system to Cast Iron Midleware (non SAP aplication).I have done all the prerequisites involved to pushing idoc----- maintain Rfc destinations,maintain port,partner prof

  • BOM Issue

    Hi all, Scenario: One Purchase order is created with a BOM material consisting of 3 components. For ex. Material X contains sub items as A, B,C. in one company code say IHK Now based on this purchase order, a Sales Oder is created for the Material X

  • Change Text on Tab of Tabbed Panel When it's Open.

    I posted this on the DW board but it was suggested I try here. I am using a tabbed panel to hide and reveal a page of text on this page: www.imagesandwords.org.uk/Don/pages/essay.php The reason I am using the tabbed panel to reveal the page is to try