Để chẩn đoán lỗi ORA-14552, chúng ta hãy xem mô tả lỗi từ Oracle:
ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
Cause: DDL operations like creation tables, views etc. and transaction control statements such as commit/rollback cannot be performed inside a query or a DML statement.
Action: Ensure that the offending operation is not performed or use autonomous transactions to perform the operation within the query/DML operation.
Nếu bắt buộc phải sử dụng commit, thì chúng ta nên sử dụng “PRAGMA AUTONOMOUS_TRANSACTION;” để commit/rollback dư liệu bằng một autonomous transaction, ví dụ như sau:
CREATE OR REPLACE FUNCTION rebuildTable
return number
as
v_table_name varchar;
pragma autonomous_transaction;
begin . . .
Leave a Review