by 춤과파티 [PL/SQL] [2018.03.08 09:03:23]
1.테이블 생성
CREATE TABLE PLANT_CHANGE_TABLE /*바뀌는 엑셀 데이터 테이블*/
(
NEW_COMPANY_CODE VARCHAR2(10);
NEW_PLANT_CODE VARCHAR2(10);
OLD_PLANT_CODE VARCHAR2(10);
);
2.프로시저 생성
create or replace PROCEDURE PLANT_CHANGE_PROCEDURE
(
TABLE_NAME VARCHAR2(50)
)
IS
CURSOR PLANT_CHANGE_CURSOR IS
SELECT NEW_COMPANY_CODE, NEW_PLANT_CODE, OLD_PLANT
FROM PLANT_CHANGE_TABLE;
AAA PLANT_CHANGE_TABLE.NEW_COMPANY_CODE%TYPE;
BBB PLANT_CHANGE_TABLE.NEW_PLANT_CODE%TYPE;
CCC PLANT_CHANGE_TABLE.OLD_PLANT_CODE%TYPE;
BEGIN
OPEN PLANT_CHANGE_CURSOR;
LOOP
FETCH PLANT_CHANGE_CURSOR INTO AAA, BBB, CCC;
EXIT WHEN PLANT_CHANGE_CURSOR%NOTFOUND;
INSERT INTO TABLE_NAME /*수정 할 테이블명*/
(
HOUSE_CODE, COMPANY_CODE, OPERATING_CODE, PLANT_CODE, PLANT_NAME_LOC, PLANT_NAME_ENG, STATUS, ADD_DATE, ADD_TIME, ADD_USER_ID, ADD_USER_NAME_LOC, ADD_USER_NAME_ENG, ADD_USER_DEPT, CHANGE_DATE, CHANGE_TIME, CHANGE_USER_ID, CHANGE_USER_NAME_LOC, CHANGE_USER_NAME_ENG, CHANGE_USER_DEPT, MAIN_PLANT_FLAG, OPERATING_TYPE
)
select
HOUSE_CODE, AAA, OPERATING_CODE, BBB, 'NEW_'||PLANT_NAME_LOC, 'NEW_'||PLANT_NAME_ENG, STATUS, ADD_DATE, ADD_TIME, ADD_USER_ID, ADD_USER_NAME_LOC, ADD_USER_NAME_ENG, ADD_USER_DEPT, CHANGE_DATE, CHANGE_TIME, CHANGE_USER_ID, CHANGE_USER_NAME_LOC, CHANGE_USER_NAME_ENG, CHANGE_USER_DEPT, MAIN_PLANT_FLAG, OPERATING_TYPE
FROM TABLE_NAME /*수정 할 테이블명*/
WHERE HOUSE_CODE = '100'
AND COMPANY_CODE = 'H100' AND PLANT_CODE = CCC and operating_code in ('1100','1101');
COMMIT;
END LOOP;
CLOSE PLANT_CHANGE_CURSOR;
END PLANT_CHANGE_PROCEDURE;
3.프로시저 실행
EXECUTE PLANT_CHANGE_PROCEDURE(TABLE_NAME);
1번 테이블을 생성한후 2번 처럼 프로시저를 생성하는데 첫번째 행인
create or replace PROCEDURE PLANT_CHANGE_PROCEDURE 에서
ORA-00911: 문자가 부적합합니다 에러가 발생합니다.
ORACLE 11G에서 작업했구요. 첫번째 행은 문제가 없는듯 하니 프로시저 문의 문법 중 한곳이 잘못된 걸까요? 콤마나 세미콜론 등은 확인해봤는데 이상 없었습니다.
무엇이 문제일까요,,,, 고민끝에 질문드립니다.