2010-03-04 34 views
2

如何从表中删除行,其中列包含子字符串,但该列的类型为“长”。 (是的,我知道我不应该使用龙,但我保持别人的混乱)。用LIKE删除匹配子字符串的行?

我第一次尝试是:

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

回答

4

我只是复制您的问题,并得到了同样的错误 - 看来这个函数不能在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; 
相关问题