Posted on 23/09/2022 12:33:12
Thank Dmitriy.
The field is now mapped in the job, but I am stil getting primary key violation, when the job is copying data from the bulk temp-table to EcomProductsRelated - RelVariantID is not part of the copied data.
insert into EcomProductsRelated (ProductRelatedProductID,ProductRelatedProductRelID,ProductRelatedGroupID) select ProductRelatedProductID,ProductRelatedProductRelID,ProductRelatedGroupID from EcomProductsRelatedTempTableForBulkImport3;
Here's the full error:
Violation of PRIMARY KEY constraint 'PK_EcomProductsRelated_1'.
Cannot insert duplicate key in object 'dbo.EcomProductsRelated'. The duplicate key value is (2444589064030, 811139021812-main, RELGRP4, ). The statement has been terminated. Sql query:
delete t1 from EcomGroupProductRelation t1 INNER JOIN ecomgroupproductrelationTempTableForBulkImport t2 ON t1.GroupProductRelationGroupID = t2.GroupProductRelationGroupID AND t1.GroupProductRelationProductID = t2.GroupProductRelationProductID;
insert into EcomGroupProductRelation (GroupProductRelationGroupID,GroupProductRelationProductID,GroupProductRelationSorting,GroupProductRelationIsPrimary) select GroupProductRelationGroupId, GroupProductRelationProductID,GroupProductRelationSorting,GroupProductRelationIsPrimary from ecomgroupproductrelationTempTableForBulkImport;
delete from EcomShopGroupRelation where ShopGroupGroupID in (select ShopGroupGroupID from EcomShopGroupRelationTempTableForBulkImport);
insert into EcomShopGroupRelation(ShopGroupShopID,ShopGroupGroupID,ShopGroupRelationsSorting) select shopgroupshopid,shopgroupgroupid,ShopGroupRelationsSorting from ecomshopgrouprelationtemptableforbulkimport;
delete from EcomVariantgroupProductRelation where VariantgroupProductRelationProductID in (select VariantgroupProductRelationProductID from EcomVariantgroupProductRelationTempTableForBulkImport);
insert into EcomVariantgroupProductRelation (VariantgroupProductRelationID,VariantgroupProductRelationProductID,VariantgroupProductRelationVariantGroupID)select VariantgroupProductRelationID,VariantgroupProductRelationProductID,VariantgroupProductRelationVariantGroupID from EcomVariantgroupProductRelationTempTableForBulkImport;
delete t1 from EcomVariantOptionsProductRelation t1 INNER JOIN EcomVariantOptionsProductRelationTempTableForBulkImport t2 ON t1.VariantOptionsProductRelationProductId = t2.VariantOptionsProductRelationProductId AND t1.VariantOptionsProductRelationVariantId = t2.VariantOptionsProductRelationVariantId;insert into EcomVariantOptionsProductRelation (VariantOptionsProductRelationProductID,VariantOptionsProductRelationVariantID)select VariantOptionsProductRelationProductID,VariantOptionsProductRelationVariantID from EcomVariantOptionsProductRelationTempTableForBulkImport;
insert into EcomShops (ShopID,ShopName) select shopid,shopname from EcomShopsTempTableForBulkImport; insert into EcomProductsRelatedGroups (RelatedGroupID,RelatedGroupName,RelatedGroupLanguageID) select RelatedGroupID,RelatedGroupName,RelatedGroupLanguageID from EcomProductsRelatedGroupsTempTableForBulkImport;
delete from related from EcomProductsRelated related where ProductRelatedProductID in (select ProductRelatedProductID from EcomProductsRelatedTempTableForBulkImport3 inside WHERE related.ProductRelatedProductID = inside.ProductRelatedProductID AND related.ProductRelatedProductRelID = inside.ProductRelatedProductRelID AND related.ProductRelatedGroupID = inside.ProductRelatedGroupID);
insert into EcomProductsRelated (ProductRelatedProductID,ProductRelatedProductRelID,ProductRelatedGroupID) select ProductRelatedProductID,ProductRelatedProductRelID,ProductRelatedGroupID from EcomProductsRelatedTempTableForBulkImport3;
delete from EcomGroupRelations where groupRelationsGroupID in (select groupRelationsGroupID from EcomGroupRelationsTempTableForBulkImport);
insert into EcomGroupRelations (GroupRelationsGroupID,GroupRelationsParentID,GroupRelationsSorting) select GroupRelationsGroupID,GroupRelationsParentID,GroupRelationsSorting from EcomGroupRelationsTempTableForBulkImport;
BR,
Christian