2017-10-06 3 views
2

나는 SQL에 익숙하지 않으며 코드에 문제가있다. 나는 테이블의 한 줄을 복사하고 레코드의 일부를 바꾸려고 노력했다. 그러나, 나는이 오류가 계속 :SQL 복사 및 바꾸기

ORA-00907: missing right parenthesis

다음 코드는 오류를 제공합니다

내가 뭐하는 거지 다음 코드를 사용하여 테이블 mi_structure이

select * 
    from mi_structure 
    where parent_mi_id like 'MIPFV%29' 
    and sysdate between startdate and enddate; 


PARENT_MI_ID || CHILD_MI_ID  || STARTDATE || ENDDATE || MUTNR 
MIPFV_POOL 29 || CSLLXXXX.USD.GR || 42917  || 36526  || 11 

과 같은

insert into mi_structure 
    select replace parent_mi_id, (child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr 
    from mi_structure 
    where parent_mi_id like 'MIPFV%29' 
    and sysdate between startdate and enddate; 

잘못된?

+0

'(child_mi_id, 'GR', 'GR_V')'는 함수처럼 작성되었지만 작성되지 않았습니다. 아마도이 오류가 발생합니다. –

+0

대체 기능을 사용하려고합니까? 그것의 사용은 REPLACE ('Atestword', 'word', 'Phrase'); = AtestPhrase – Moudiz

답변

1

당신은 당신이 삽입 등의 열을 추가 운영자 추천이

insert into mi_structure 
    select parent_mi_id, replace (child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr from mi_structure 
    where parent_mi_id like 'MIPFV%29' 
    and sysdate between startdate and enddate; 
+0

도와 주셔서 감사합니다. 이것은 예상대로 업데이트 된 라인을 제공합니다. 이것도 테이블에 레코드를 추가합니까? – Roosz0rd

+0

그것은 유일한 선택 부분입니다, 당신은 또한 삽입 부분을 작성해야합니다. 나는 또한 삽입 부분을 추가했습니다 –

+0

'insert into mi_structure'무결성 제약 조건을 받았습니다. – Roosz0rd

2

select replace parent_mi_id, (child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr from mi_structure

는 당신이 아래의 BTW

insert into mi_structure (parent_mi_id_col,child_mi_id_col,startdate_col,enddate,mutnr) 
    select parent_mi_id, replace(child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr 
    from mi_structure 
     where parent_mi_id like 'MIPFV%29' 
     and sysdate between startdate and enddate; 

같아야 잘못된 기능을 대체 사용하는 것 시도 할 수 위.

+0

하지만 헤더가 올바른 순서가 아닙니다. 그게 문제가 아닌가? 그러면 이것이 테이블에 선을 추가합니까? – Roosz0rd

+0

삽입물이 있으면 문제가 발생합니다. 삽입 부분을 추가하십시오. btw 나는 내 예제와 같이 삽입에 열을 추가하는 것이 좋습니다. – Moudiz