如何从表中删除行,其中某列包含子字符串,但该列的类型为“Long”。 (是的,我知道我不应该使用 Long,但我正在维护别人的困惑)。
我的第一次尝试是:
delete from longtable
where search_long(rowid) like '%hello%';
(继this answer之后。)
这将返回:
SQL Error: ORA-04091: table blah.longtable is mutating, trigger/function may not see it
最佳答案
我刚刚复制了您的问题并得到了相同的错误 - 似乎该函数无法在 DELETE 语句中工作。错误全文为:
ORA-04091: table HOU.LONGTABLE is mutating, trigger/function may not see it
ORA-06512: at "TONY.SEARCH_LONG", line 4
这种程序方法将会起作用:
begin
for r in (select id from longtable
where search_long(rowid) like '%hello%')
loop
delete longtable where id = r.id;
end loop;
end;
关于sql - 删除与 LIKE 子字符串匹配的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2381203/