Violation of Primary Key after a successful Update of BP

When I've updated a BP via VB.net is there something I should do with the BP object after I've done an update?
I can't seem to do consecative updates or I get the following error:
Violation of PRIMARY KEY constraint 'CRD1_PRIMARY'. Cannot insert duplicate key in object 'CRD1'
This is the code I use for updating:
For i = 0 To oBusinessPartner.Addresses.Count - 1
            oBusinessPartner.Addresses.SetCurrentLine(i)
            If (oBusinessPartner.Addresses.AddressType = SAPbobsCOM.BoAddressType.bo_ShipTo) Then
                '** Check only SHIP TO Addresses
                If (oBusinessPartner.Addresses.AddressName = cbSAPShipTo.SelectedItem) Then
                    '** Address User wishes to update
                    oBusinessPartner.Addresses.AddressType = SAPbobsCOM.BoAddressType.bo_ShipTo
                    oBusinessPartner.Addresses.AddressName = lSAPAddressItems(iIndex).Company
                    oBusinessPartner.Addresses.Street = lSAPAddressItems(iIndex).Address1
                    oBusinessPartner.Addresses.City = lSAPAddressItems(iIndex).City
                    oBusinessPartner.Addresses.ZipCode = lSAPAddressItems(iIndex).Postal
                    oBusinessPartner.Addresses.State = lSAPAddressItems(iIndex).Prov
                    oBusinessPartner.Addresses.Country = lSAPAddressItems(iIndex).Country
                End If
            End If
        Next
        lRetCode = oBusinessPartner.Update()
I check to make sure the address i want to up date is a ShipTo address, then I check to make sure that the item I am editing matches the one in the BPObject's CurrentLine.
Then I just change the values and .Update() it
After I've done this though, if I try to update another ShipTo address in the same BP, it comes up with that error.
Should I kill the BP object and reinitialize it?

Hi Tyler,
I totally understand what you wanna do.
The clauses which you use is trying to add a new address in the name of existing address.
You have to do 'setcurrentline' clause, I guess.
But now, you don't know 'what is the ShipTo line'.
Then, I think you'd better use some simple, easy but timely expensive way.
1. Count the records in CRD1 under conditions of the cardcode.
-> then you can get the number of addresses of the business partner.
2. use a loop (while, for.. doesn't matter.)
-> Now you can use setcurrentline clause.
3. If the addressname is 'ShipTo', then you can update the record, and exit loop.
pseudo code comes below.
sql = "Select count(*) FROM OCRD WHERE cardcode = 'aaa'"
ors.doquery sql
for i=1 to ors.fields.item(0)
oBusinessPartners.Addresses.setcurrentline(i)
if obusinessPartners.Addresses.AddressName = "ShipTo" then
oBusinessPartners.block = "newBlock"
exit for
end if
next i
Hope this useful for you.
Regards,
Hyunil choi.

Similar Messages

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

  • 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 'XPKLocalizedLabel'. Cannot insert duplicate key in object 'MetadataSchema.LocalizedLabel'.

    Hello everyone,
    I am getting the following error while importing the CRM 2013 managed solution, Does anyone have any idea regarding this, What could be the possible cause for this ?
    "Violation of PRIMARY KEY constraint 'XPKLocalizedLabel'. Cannot insert duplicate key in object 'MetadataSchema.LocalizedLabel'. The duplicate key value is (184191c0-1d6f-e411-9400-e41f13be2efc, 25a01723-9f63-4449-a3e0-046cc23a2902, 0,
    Jan 1 1900 12:00AM). The statement has been terminated."
    and this guids in the error message is different from organization to organization. Where it is having fix with the solution or organization ?
    please help me to solve this.
    Thanks in advance, Veeresh

    Hi All,
    I have exported one unmanaged solution from my development CRM system and imported in to production, while importing i am getting the following error. 
    "Violation of PRIMARY KEY constraint 'XPKLocalizedLabel'. Cannot insert duplicate key in object 'MetadataSchema.LocalizedLabel'. The duplicate key value is (184191c0-1d6f-e411-9400-e41f13be2efc, 25a01723-9f63-4449-a3e0-046cc23a2902,
    0, Jan 1 1900 12:00AM).
    The statement has been terminated."
    The key point i have noticed here is, recently i have updated my CRM system with server pack 1 and development organization is created after the server pack is installed and production organization is created before the server pack is installed. and
    i have tried this in some other organization which is created before the server pack 1 installed it is failed there also and some organization which is created after the server pack 1 is installed it is imported successfully.
    so i can see here it is not able to import solution into organization which is created before server pack 1 is installed from which is created after the server pack 1 is installed.
    please help me to solve this error.
    Thanks,
    Veeresh
    Thanks in advance, Veeresh

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

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

  • 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

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

    Hello,
    I have the following table in my oracle database :
    create table FLTRPTDATA
    esn VARCHAR2(10) default 'ALL' not null,
    periodid NUMBER not null,
    yearid NUMBER default 2007 not null,
    reportid NUMBER not null,
    entryid NUMBER not null,
    operatorid VARCHAR2(30) default 'XXX' not null,
    param1 VARCHAR2(200),
    param2 VARCHAR2(200),
    param3 VARCHAR2(200),
    param4 VARCHAR2(200),
    param5 VARCHAR2(200),
    param6 VARCHAR2(200),
    param7 VARCHAR2(200),
    param8 VARCHAR2(200),
    param9 VARCHAR2(200),
    param10 VARCHAR2(200),
    acid VARCHAR2(8) default 'ALL' not null
    and also have a composite primary key for the table as follows :
    add constraint PK_FLTRPTDATA primary key (ESN, PERIODID, YEARID, REPORTID, ENTRYID, OPERATORID, ACID)
    using index
    So I expect that I can only insert a new row into the table if the combination of values for ESN,PERIODID,YEARID,REPORTID,ENTRYID,OPERATORID and ACID are unique.
    I am running some software that inserts new rows into the table (via an INSERT SQL statement).
    When the software runs, it inserts a certain number of rows, but then stops when inserting one of the rows with a Violation of PRIMARY KEY constraint 'PK_FLTRPTDATA'. Cannot insert duplicate key in object 'fltRPTDATA' error.
    This implies that the row being inserted contains values for the composite key columns that are NOT unique. However, when I look at the data it fails to insert, I can see that there are NO rows in the table for this combination of column values.
    If I then try to MANUALLY insert the same row myself (via my own SQL statement in SQL Developer), the row is inserted with no error.
    When I run the software, the first thing it does is delete any rows in the table that it will subsequently insert, so there cannot be any duplicate entries in the table before the inserts take place. I have run the SQL statement that does the deletion myself manually, and it does delete all of the relevant rows.
    I have checked the code (I am not the author), and I cannot see anything that would cause the same INSERT to be executed twice.
    I have checked the log file generated by the software, and the INSERT is only attempted once (according to the log).
    I don't understand why the insert fails when I run the software, and I am wondering if anyone can shed any light on the issue? Has anyone seen this scenario before where you get a PRIMARY KEY constraint violation on a composite key, where the data being inserted IS unique?
    Thanks for any help and apologies if this is in the wrong forum,
    Jason.

    >
    I don't understand why the insert fails when I run the software, and I am wondering if anyone can shed any light on the issue? Has anyone seen this scenario before where you get a PRIMARY KEY constraint violation on a composite key, where the data being inserted IS unique?
    >
    One way to find those records would be to create and use a dml error log table. Then those records would get logged to the log table and would not prevent the insert of the valid records.
    See Loading Tables in the DBA Guide
    http://docs.oracle.com/cd/E11882_01/server.112/e17120/tables004.htm#InsertDMLErrorLogging
    Then you can examine the records in the log table and see why they were rejected.

  • Violation of PRIMARY KEY constraint 'PK_POP'

    Hi
    When i am creating a new interface in ODI. On saving it the following error pops up:
    com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_POP'. Cannot insert duplicate key in object 'dbo.SNP_POP'.
    The error is irrespective of the datastores i use to create the interface
    Any help appreciated

    question for you , Is this a new work repository or a migrated Work repository and if migrated , does it have the same Work repository Id as that of the source ?
    It looks like the new Incrementing Internal Id which ODI is trying to create is already present in Work repository and which is causing to PK constraint on SNP_POP.
    Also try this , try duplicating any old interface and are you still getting the same error message?

  • 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) ?

    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

    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

  • Violation of PRIMARY KEY constraint during sending NCCode to system

    MES system is: (6.0.4.22)
    External software is sending NCData to MES system and sometimes gets error:"Violation of PRIMARY KEY constraint 'PK__BC_JMSQU__3F9FE7012CDE6A9D'. Cannot insert duplicate key in object 'SAPEL1DB.BC_JMSQUEUE'. The duplicate key value is (36, 26015261174081363, 3500000000000000001)"
    I provide client machine log with data details in file: "client device.txt"
    and default trace part in file: "default_trace.txt"

    Hi!
    You might be using NC Codes with Message Type assigned or you turned on RTW for NC. Please check if disabling these features makes any change.
    Also you can play with "Enable SFC Complete JMS Message" system rule.
    Regards,
    Sergiy

  • Help me to return the primary key after insert the row

    Hi
    I am using JDBC, with oracle database. i have welformed normalization tables .i am inserting parent table with dynamic sequence number as primary key .after inserting i need inserted row primary key .how to get the inserted row primary key with out using select statement
    please help me
    Thanks in advance
    Edited by: 849614 on Apr 4, 2011 5:41 AM
    Edited by: 849614 on Apr 4, 2011 5:54 AM

    Hello
    If I undestand you, I think you should do this:
    Connection conexion = dataSource.getConnection();
    int idCenter=-1;
    String query = "Begin Insert into CENTER (NAME_CENTER) values (?) returning ID_CENTER into ?; end";
    callableStatement = conexion.prepareCall(query.toString());     
         callableStatement.setString(1, "Center name");               
         callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
              callableStatement.executeUpdate();
              idCenter=callableStatement.getInt(2);
    This way, you have in idCenter the primary key of the line that has just been inserted.
    Edited by: cris on 05-abr-2011 5:28

  • Missing Primary Keys after migartion of a MSAccess 2003 DB to oracle 9.i

    I migrate a MS Access 2003 DB to Oracle 9.i with the Oracle Migration Workbench 10.1.0.4.0. on a Windows 2k PC. All the Primary Keys of my tables are missed after migration and no Foreign Key is created.
    In the MS Access Source Model Window of OMWB are the Primary Keys detected but in migration script or in oracle db after migration there is no Primary Key applied.
    Dos anyone kows the reason for this behavior.
    Thanks for help in advance.
    Message was edited by:
    user468547
    Message was edited by:
    user468547

    Here the summary of the Model.
    Not mentioned parts are sero in the Oracle Model
    MS Access Source Model
    Table Violation Rules (0)
    Relations ( 48)
    Indexes (96)
    Primary Keys (38)
    Queries (0)
    Tables (38)
    Oracle Model
    Database (1)
    Check Constraints (0)
    Foreign Keys (48)
    Indexes (96)
    Primary Keys /Unique ... (0)
    Tables (38)
    Types (2)
    In the migration scripts the commands for creation of Foreign Keys are avaliable and delievers the error message ORA-02270. e.g.
    REM
    REM Message : Failed to create foreign key: dbwines.TBL_SERVICEPROFILESTBL_UETYPES; ORA-02270: no valid Primr- o. eindeutiger Key for this column
    Here the content of the error.log
    ** Workbench Repository : Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Repository Connection URL: jdbc:oracle:thin:@pcathlon17002:1521:ORCL
    ** The following plugins are installed:
    ** Microsoft Access 2.0/95/97/2000/2002/2003 Plugin, Production Release 10.1.0.4.0
    ** Active Plugin : MSAccess
    oracle.mtg.migration.MigrationSQLException: Failed to get information about Oracle Model Object.
    Erschpfte Ergebnismenge:Failed to get information about Oracle Model Object.
    Erschpfte Ergebnismenge
         at oracle.mtg.oracleModel.server.OracleModelImpl.getObjectInformation(OracleModelImpl.java:476)
         at oracle.mtg.oracleModel.ui.OracleModelTypes.getAllChildren(OracleModelTypes.java:95)
         at oracle.mtg.plugin.ui.WorkbenchAllTreeNode.getChildren(WorkbenchAllTreeNode.java:133)
         at oracle.mtg.migrationUI.TreeDataSource.getItemCount(TreeDataSource.java:128)
         at oracle.ewt.dTree.DTreeDeferredParent.getItemCount(Unknown Source)
         at oracle.ewt.dTree.DTreeBaseItem.isExpandable(Unknown Source)
         at oracle.ewt.dTree.DTreeButtonDecoration.getHasButton(Unknown Source)
         at oracle.ewt.dTree.DTreeButtonDecoration.paintDecoration(Unknown Source)
         at oracle.ewt.dTree.DTreeStackingDecoration.paintDecoration(Unknown Source)
         at oracle.ewt.dTree.DTree.paintCanvasInterior(Unknown Source)
         at oracle.ewt.EwtComponent.paintInterior(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter._paintInterior(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.EwtComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.EwtComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.EwtComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.EwtComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.EwtComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent._paintComponent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.paint(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paintExtents(Unknown Source)
         at oracle.ewt.lwAWT.SharedPainter.paint(Unknown Source)
         at oracle.ewt.lwAWT.BufferedApplet.paint(Unknown Source)
         at oracle.ewt.lwAWT.BufferedApplet.update(Unknown Source)
         at sun.awt.RepaintArea.paint(Unknown Source)
         at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    ** Shutdown : Mon Apr 10 18:36:10 CEST 2006
    ** Oracle Migration Workbench
    ** Production
    ** ( Build 20050629 )
    ** OMWB_HOME: C:\oracle\ora92\omwb
    ** user language: de
    ** user region: null
    ** user timezone:
    ** file encoding: Cp1252
    ** java version: 1.4.2_04
    ** java vendor: Sun Microsystems Inc.
    ** o.s. arch: x86
    ** o.s. name: Windows 2000
    ** o.s. version: 5.0
    ** Classpath:
    ..\lib\boot.jar
    ** Started : Mon Apr 10 18:36:14 CEST 2006
    ** Workbench Repository : Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Repository Connection URL: jdbc:oracle:thin:@pcathlon17002:1521:ORCL
    ** The following plugins are installed:
    ** Microsoft Access 2.0/95/97/2000/2002/2003 Plugin, Production Release 10.1.0.4.0
    ** Active Plugin : MSAccess
    EXCEPTION : query()java.sql.SQLException: Stream wurde schon geschlossen
    select MESSAGE_TYPE, LOG_ID, TO_CHAR(LOG_DATE, 'dd-MM-yyyy hh24:mi:ss') LOG_DATE, PROJECT_ID, PHASE, SUBPHASE, LOG_MESSAGE, OBJECT_TYPE, OBJECT_ID, CONTEXT_DATA from MTG_LOG_TABLE WHERE PROJECT_ID = 1 and (MESSAGE_TYPE != 9999) ORDER BY LOG_ID ASC
    java.lang.NullPointerException
         at oracle.mtg.migration.LogDisplayUtility.convertToDisplayStrings(LogDisplayUtility.java:185)
         at oracle.mtg.migrationServer.LoggingImpl.getLogs(LoggingImpl.java:482)
         at oracle.mtg.migrationUI.LoggingPane.setupLogTable(LoggingPane.java:291)
         at oracle.mtg.migrationUI.LoggingPane.setupLogTable(LoggingPane.java:280)
         at oracle.mtg.migrationUI.ProgressDialog.commandStarting(ProgressDialog.java:117)
         at oracle.mtg.migrationUI.MigrationUI.commandStarting(MigrationUI.java:2427)
         at oracle.mtg.migrationUI.MigrationWizard.doMigrate(MigrationWizard.java:401)
         at oracle.mtg.migrationUI.MigrationWizard.runDialog(MigrationWizard.java:293)
         at oracle.mtg.migrationUI.ActionMenuHandler._migrate(ActionMenuHandler.java:340)
         at oracle.mtg.migrationUI.ActionMenuHandler._capture(ActionMenuHandler.java:291)
         at oracle.mtg.migrationUI.ActionMenuHandler.run(ActionMenuHandler.java:85)
         at oracle.mtg.migration.WorkerThread.run(Worker.java:268)
    ** Workbench Repository : Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Repository Connection URL: jdbc:oracle:thin:@pcathlon17002:1521:ORCL
    ** The following plugins are installed:
    ** Microsoft Access 2.0/95/97/2000/2002/2003 Plugin, Production Release 10.1.0.4.0
    ** Active Plugin : MSAccess
    Thaks for help in advance
    Regards Steffen

  • Problem with primary key field that needs updating on commit

    Taking on someone else's form and trying to tidy it up as it has no primary key on tha table.
    The only primary key i can apply is (invoice number, line number)
    This has to be displayed on the form as a provisional number when the user enters the form. So it need to show for example inv number 1000 with each line on the invoice being 1,2,3,4 etc.
    The form then has a linked table for the lines per invoice that inserts invnumber and line number into a seperate table on PRE INSERT trigger. This means that if they put on various lines i need to do a post.
    My problem comes because more than one person can use the form at the same time so user a will go into the form and see inv number 1000, user b will also see 1000. The original form was making these null and updating to correct number on commit but i wanted to add a primary key.
    Im jusat wodering the best way to do this as if user a does not save before user b. there is a potential for a lock to occur on the post. Also they must be updated to a new number if someone else saves before them

    either you create a sequence for this by create sequence command and populate the sequence value. but in this case if the form is cancelled the sequence is missed and the next sequence will appear. Another way to do is to generate the invoice number when the user press save button and then assign that value to text item. It is the best way to do. So the user will see invoice number only when they save and it happens in milli seconds so there is no question of overlapping invoice number.
    Hope this helps.

Maybe you are looking for

  • Purchase price variant report

    i have attached the source code i have written, could you please tell me why matnr number  purchase order and item  (matnr, ebeln, eblep)  , but i am geeting all other fields ine the output it_final but i am getting in it_po but not in it_final, plea

  • Unable to install Windows 7 via Bootcamp

    I have an early 2008 Apple Mac Pro Dual 2.8 GHZ processors with 16 GB of RAM. I have a WD Veliciraptor 300 GB hard drive in Bay 1 and a WD 320 GB drive in bay two. After I got the Mac system set up with all of my programs/user accounts/software updat

  • Itunes store -42404 error

    So everytime I try to download anything from the store on my computer i get this error. i have updated itunes, uninstalled and reinstalled, but nothing fixed it. Any help?

  • Error -8 when trying video (another error log...)

    I can text chat, but cannot audio/video chat with several people. All of us can connect to the test accounts but not with each other. Is there something I can do? This is the error message I get: Date/Time: 2008-04-24 21:44:35.962 -0500 OS Version: 1

  • Can Badi WF_SUBSTITUTE be used for SRM approval substitution

    Hi, We have a requirement where we want the substitutes (active and passive) to be restricted by roles. That is when the approver is assiging the substitute system should allow him to assign the substitute with users with Manager roles only. Is it po