Developer forum

Forum » Integration » Assortment import primary key issue

Assortment import primary key issue

Gaëtan Di Caro
Reply

Hello,

 

I'm trying to import assortments to a DW 9.4.12. If the assortments tables (EcomAssortments, EcomAssortmentProductRelations, EcomAssortmentPermissions) are empty, it runs fine and it works after. However if I try to run it a second time, I get a primary key error :

Job Failed with the following message: failed to move data from temporary table [dbo.EcomAssortmentPermissionsTempTableForBulkImport4] to main table [dbo.EcomAssortmentPermissions]. Exception: Violation of PRIMARY KEY constraint 'PK_EcomAssortmentPermissions'. Cannot insert duplicate key in object 'dbo.EcomAssortmentPermissions'. The duplicate key value is (SB222111, 463). The statement has been terminated. Sql query: update [dbo].[EcomAssortmentPermissions] set [AssortmentPermissionAccessUserID]=[dbo].[EcomAssortmentPermissionsTempTableForBulkImport4].[AssortmentPermissionAccessUserID] from [dbo].[EcomAssortmentPermissionsTempTableForBulkImport4] where [dbo].[EcomAssortmentPermissions].[AssortmentPermissionAssortmentID]=[dbo].[EcomAssortmentPermissionsTempTableForBulkImport4].[AssortmentPermissionAssortmentID] ; insert into [dbo].[EcomAssortmentPermissions] ([AssortmentPermissionAssortmentID],[AssortmentPermissionAccessUserID]) (select [dbo].[EcomAssortmentPermissionsTempTableForBulkImport4].[AssortmentPermissionAssortmentID], [dbo].[EcomAssortmentPermissionsTempTableForBulkImport4].[AssortmentPermissionAccessUserID] from [dbo].[EcomAssortmentPermissionsTempTableForBulkImport4] left outer join [dbo].[EcomAssortmentPermissions] on [dbo].[EcomAssortmentPermissions].[AssortmentPermissionAssortmentID]=[dbo].[EcomAssortmentPermissionsTempTableForBulkImport4].[AssortmentPermissionAssortmentID] where [dbo].[EcomAssortmentPermissions].[AssortmentPermissionAssortmentID] is null);

 

I'm sure my data source doesn't have any duplicate, and they two only fields I import are defined as key (see screenshot). Is there something wrong with my setup ?

2018-07-26_09_26_22-Larsen_Strings.png

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi GaĆ«tan,
try to set the Key Columns to:
AssortmentPermissionAssortmentID
AssortmentPermissionAccessUserID

As "AssortmentPermissionExternalID" is a virtual column and may be a cause here.
Regards, Dmitrij 

Votes for this answer: 1
 
Gaëtan Di Caro
Reply

Thanks Dmitriy, it worked :)

 

You must be logged in to post in the forum