Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 不再工作的代码_Sql_Oracle_Oracle11g - Fatal编程技术网

Sql 不再工作的代码

Sql 不再工作的代码,sql,oracle,oracle11g,Sql,Oracle,Oracle11g,这段代码是编写的,并且已经运行了几个月。然而,前一天有一些Oracle更新,现在这段代码不再工作了。基本上,此代码会删除重复项 delete from integration where rowid in ( select rowid from ( select rowid, intg.*, RANK() OVER (PARTITION BY intg.pid ORDER BY intg.rowid DESC) rk from integrat

这段代码是编写的,并且已经运行了几个月。然而,前一天有一些Oracle更新,现在这段代码不再工作了。基本上,此代码会删除重复项

 delete from integration where rowid in (
     select rowid from (
          select rowid, intg.*, RANK() OVER (PARTITION BY intg.pid ORDER BY intg.rowid DESC) rk
          from integration intg where pid||to_char(entry_date, 'dd.mm.yyhh:mi:ss') in (
               select pid||to_char(entry_date, 'dd.mm.yyhh:mi:ss') from integration
               group by pid, entry_date
               having count(pid) > 1
          )
     ) where rk = 1
);
当我执行这段代码时,它就一直在执行。是的,没有重复项,所以我应该只得到空结果,而不是死死执行..有什么办法可以解决这个问题吗


干杯

您的sql有几个步骤。这需要多长时间

select pid||to_char(entry_date, 'dd.mm.yyhh:mi:ss') 
from integration
group by pid, entry_date
having count(pid) > 1
这个呢

select rowid, 
       intg.*, 
       RANK() OVER (PARTITION BY intg.pid ORDER BY intg.rowid DESC) rk
       from integration intg 
       where pid||to_char(entry_date, 'dd.mm.yyhh:mi:ss') in (select pid||to_char(entry_date, 'dd.mm.yyhh:mi:ss') 
                                                                 from integration
                                                                 group by pid, entry_date
                                                                 having count(pid) > 1
                                                                )

您试图删除的数据上是否有其他锁?您可以在pl/sql developer中使用工具->会话或使用字典表(例如v$lock)查找有关锁的信息,如果怀疑有锁,您可以尝试选择相同的行进行更新nowait,如果这些行被锁定,它将立即返回