关于"cannot perform a DDL, commit or rollback inside a query or DML" 错误

error scenario:

update a set field1 = functionA() where ...

function functionA return varchar2 as

begin

...

 -- may be

 raise_application_error(-20000,'TEST');

...

EXCEPTION

 WHEN OTHERS THEN

  log_to_table(...)

  Commit;

end functionA;

Most of the time, functionA will not cause any problem. It log into log table when error happens inside of it. And commit the log.

But , Some time it will cause issue when functionA was called from an update statement(DML statement) as a value passed to "set" clause.

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

Resolve solution:

1, in this situation we can apply "autonomous transaction" to log_to_table, and remove the "Commit" . this solution will cause some performance loss.

2, remove "commit". "commit" transaction after "update..."(DML).

转载于:https://www.cnblogs.com/wzc998/archive/2011/08/16/2140199.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值