Dev/DataBase
ORA-14551: cannot perform a DML operation inside a query
nakanara
2022. 8. 18. 12:09
반응형
ORA-14551 cannot perform a DML operation inside a query
Cause: DML operation like insert, update, delete or select-for-update cannot be performed inside a query or under a PDML slave.
Action: Ensure that the offending DML operation is not performed or use an autonomous transaction to perform the DML operation within the query or PDML slave.
Function 내부에서 DML 이 사용된 경우 발생하는 오류입니다.
함수에서 DML이 필요한 경우 다음으로 처리합니다.
FUNCTION myFunc (
V_PARAM IN VARCHAR2
) RETURN NVARCHAR2 AS
PRAGMA AUTONOMOUS_TRANSACTION; -- 추가 필요
V_RETURN NVARCHAR2(10);
BEGIN
V_RETURN := 'SUCCESS';
INSERT INTO EMP(EMPNO, EMP_NAME) VALUES (1, 'EMP');
UPDATE EMP SET EMP_NAME = 'EMP' WHERE EMPNO = '1';
DELETE EMP WHERE EMPNO = '1';
COMMIT; -- 추가 필요
RETURN V_RETURN;
END;
반응형