Translate

Tuesday, March 31, 2015

unique constraint (MSC.MSC_ITEM_SOURCING_U1) violated

Run the following SQL against this table to find the bad rows:
select
mis.inventory_item_id item_id
, mis.organization_id org_id
, mis.source_organization_id src_org
, mis.assignment_id asg_id
, mis.sourcing_rule_id src_rul_id
, mis.assignment_type asg_typ
from
msc_item_sourcing_bad mis,
(select
ORGANIZATION_ID,
SR_INSTANCE_ID,
INVENTORY_ITEM_ID,
SOURCE_ORGANIZATION_ID,
SR_INSTANCE_ID2,
SUPPLIER_ID,
SUPPLIER_SITE_ID,
EFFECTIVE_DATE,
SHIP_METHOD,
CUSTOMER_ID,
CUSTOMER_SITE_ID,
ZONE_ID,
ASSIGNMENT_SET_TYPE,
RANK,
CIRCULAR_SRC,
ITEM_TYPE_VALUE,
count(*)
from msc_item_sourcing_bad
group by
ORGANIZATION_ID,
SR_INSTANCE_ID,
INVENTORY_ITEM_ID,
SOURCE_ORGANIZATION_ID,
SR_INSTANCE_ID2,
SUPPLIER_ID,
SUPPLIER_SITE_ID,
EFFECTIVE_DATE,
SHIP_METHOD,
CUSTOMER_ID,
CUSTOMER_SITE_ID,
ZONE_ID,
ASSIGNMENT_SET_TYPE,
RANK,
CIRCULAR_SRC,
ITEM_TYPE_VALUE
having count(*) > 1
order by
INVENTORY_ITEM_ID
, ORGANIZATION_ID
,SOURCE_ORGANIZATION_ID ) dup_src
where
and mis.inventory_item_id = dup_src.inventory_item_id
and mis.organization_id = dup_src.organization_id
and mis.source_organization_id = dup_src.source_organization_id
;
Now using the SQL output, you can correct the bad records and resolve the issue

No comments:

Post a Comment