So, I ahve had a lot of errors the past year now, and this one is a new one to me. Anybody have this before?
Error Detail
Message: An error occurred while updating the entries. See the inner exception for details.
Inner Exception Message: Violation of PRIMARY KEY constraint ‘PK_CustCnAttr’. Cannot insert duplicate key in object ‘Erp.CustCnAttr’. The duplicate key value is (VT, 331, 00127, 1, ).
The statement has been terminated.
Program: Epicor.ServiceModel.dll
Method: ShouldRethrowNonRetryableException
Client Stack Trace
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Erp.Proxy.BO.CustCntImpl.Update(CustCntDataSet ds)
at Erp.Adapters.CustCntAdapter.OnUpdate()
at Ice.Lib.Framework.EpiBaseAdapter.Update()
at Erp.UI.App.CustomerEntry.Transaction.UpdateContacts()
Inner Exception
Violation of PRIMARY KEY constraint ‘PK_CustCnAttr’. Cannot insert duplicate key in object ‘Erp.CustCnAttr’. The duplicate key value is (VT, 331, 00127, 1, ).
The statement has been terminated.
Violation of PRIMARY KEY constraint ‘pk_Company_ID’. Cannot insert duplicate key in object ‘dbo.SonicOutBound’. The duplicate key value is (001, 834137).
This is the sql job script it is trying to run. I’m not even sure what the script is trying to do but it is erroring out.
use Status
set transaction isolation level read uncommitted
declare @ID as int;
declare @Company as varchar(5);
declare @LineCount as int;
declare @Date as datetime;
set @Date = getdate()
–XXX
set @Company = ‘001’
set @ID = (select MAX(ID) from SonicOutBound)
set @ID = @ID+1
set @LineCount = (select Count(*) from EpicorTest905.dbo.intqueout as E where company = @Company)
IF @LineCount > 0
insert into SonicOutBound(Company, SonicOutBoundCount,ID,Date)
select E.company, Count(*),@ID,@Date from EpicorTest905.dbo.intqueout as E
where company != ‘vn10t’
Group By Company
ELSE
insert into SonicOutBound(Company, SonicOutBoundCount,ID,Date)
values(@Company, ‘0’,@ID,@Date)
Seems like whoever made your SonicOutBound table made Company a primary key - which means you cant have more than one. But the code appears to be trying to make multiple records with same company
Either they need to change the primary key or they intended to update existing records, instead of adding them