设为首页 加入收藏

TOP

ORA-14551:无法在查询中执行DML操作的解决方法
2014-11-24 02:37:52 来源: 作者: 【 】 浏览:0
Tags: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. www.2cto.com
*/
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
摘自 gdolphinw的专栏
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle中DECODE函数的用法 下一篇oracle中的decode

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: