두 테이블, adv_institution
및 institution
이 있습니다. adv_institution
내가 institution
에서 adv_institution
에 레코드를 백 채우기 위해 오라클 MERGE를 사용하려면 1400ORA-00001 : 고유 제약 (MYUSER.ADI_PK)이 위반되었습니다
있는 동안 institution
는 5000 개 행이 있습니다. 이 두 테이블에는 백필에 사용할 수있는 주석 약 4 개의 필드가 있습니다. 여기
merge into
adv_institution to_t
using (
select
uni.*,
adv_c.country_cd as con_code_text
from
(
select
institution_cd,
name,
institution_status,
country_cd
from
institution uni
where
uni.institution_status = 'ACTIVE' and
uni.country_cd is not null
group by
institution_cd,
name,
institution_status,
country_cd
order by
name
) uni,
country_cd c_cd,
adv_country adv_c
where
uni.country_cd = c_cd.country_cd and
c_cd.description = adv_c.country_cd
) from_t
on
(
to_t.VENDOR_INSTITUTION_CD = from_t.INSTITUTION_CD or
to_t.INSTITUTION_CD = from_t.NAME
)
WHEN NOT MATCHED THEN INSERT (
to_t.INSTITUTION_CD,
to_t.INSTITUTION_NAME,
to_t.SHORT_NAME,
to_t.COUNTRY_CD,
to_t.NOTE,
to_t.UNIT_TERMINOLOGY,
to_t.COURSE_TERMINOLOGY,
to_t.CLOSED_IND,
to_t.UPDATE_WHO,
to_t.UPDATE_ON,
to_t.CALLISTA_INSTITUTION_CD
)
VALUES (
from_t.NAME,
from_t.NAME,
'',
from_t.con_code_text,
'',
'UNIT',
'COURSE',
'N',
'MYUSER',
SYSDATE,
from_t.institution_cd
);
내가 가진 오류는
오류 보고서입니다 - ORA-00001 : 고유 제한 조건 (MYUSER.ADI_PK)
ADI_PK
수단을 위반 adv_institution.institution_cd
은 기본 키이며 고유해야합니다.
WHEN NOT MATCHED THEN INSERT
에는 삽입 문이 있기 때문입니다. 을 to_t.INSTITUTION_CD
에 삽입합니다.
(
select
institution_cd,
name,
institution_status,
country_cd
from
institution uni
where
uni.institution_status = 'ACTIVE' and
uni.country_cd is not null
group by
institution_cd,
name,
institution_status,
country_cd
order by
name
) uni
내가 이해하지 확신 : from_t.NAME
가 같은 값을 가지고 같은 to_t.INSTITUTION_CD
에 삽입하지만 확실히 from_t.NAME
를 만들기 위해 그룹 문을했을 때
그것은 고유 한, 두 번 이상 찾습니다 문제가 올바르게 해결되었습니다. 내가 할 수있는 모든 노력을했지만 여전히 운이 없다.