oracle 中为什么在一个存储函数里不能同时进行查询和更新操作
我要写一个存储函数,该函数是这样实现的
我先声明一个cursor,然后open,
在循环fetch,每次fetch后我都要对该表的一个字段进行update
可我执行该函数时,出现下列错误.
SQL> select jiqing from dual;
select jiqing from dual
*
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "ORACLE.MARKS", line 4
ORA-06512: at "ORACLE.JIQING", line 21
ORA-06512: at line 1
其中,MARKS是更新字段的存储函数
我查了一下错误代码,如下
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
我现在是不懂,难道再一个存储函数里不能,对一个表同时进行查询
和更新?望各位大虾指教