[英]Oracle / update query inside pipelined table function
I have a pipelined table function that work fine.我有一个工作正常的流水线表函数。
what I need now is to perform an update query inside this function:我现在需要的是在这个函数中执行更新查询:
create or replace FUNCTION test(A varchar2 )
RETURN type_As PIPELINED as row_type type_A;
Begin
....
update X set A=0 where B=1;
select type_A(...)
into row_type
from dual;
PIPE ROW(row_type);
return ;
end;
When I run this query :当我运行此查询时:
SELECT * from TABLE(test('123'))
SELECT * from TABLE(test('123'))
I get this error:我收到此错误:
ORA-14551:cannot perform a DML operation inside a query
ORA-14551: 无法在查询中执行 DML 操作
So it's clear that a cannot add the update query here , so how to perform the update instead ?所以很明显a不能在这里添加更新查询,那么如何执行更新呢?
Any help is appreciated.任何帮助表示赞赏。
Try to add尝试添加
pragma autonomous_transaction;
to your function and use dynamic SQL for your update.到您的函数并使用动态 SQL 进行更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.