ORA-14551: 无法在查询中执行 DML 操作 解决方法
--创建测试表
create table fn_dml_test
(
ID NUMBER(20),
text VARCHAR2(200)
)
--创建函数
CREATE OR REPLACE FUNCTION fn_test(ID NUMBER) RETURN NUMBER
IS
/*
14551, 00000, "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.
*/
pragma AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO fn_dml_test(id,text) values(ID,'success');
COMMIT;
RETURN 1;
EXCEPTION
WHEN OTHERS THEN
INSERT INTO fn_dml_test(id,text) values(ID,'fail');
COMMIT;
RETURN 0;
END;
--查询验证
SELECT fn_test(1) from dual
更多Oracle相关信息见Oracle 专题页面 ?tid=12
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号