Oracle用游标删除重复数据

CREATE OR REPLACE 
PROCEDURE PR_MOD_BASE 
IS

cursor c_base IS
SELECT MIN(INVENTORY_DATE) IDATE,KUNNR,MATNR FROM STOCK_BASE_DATA GROUP BY TO_CHAR(INVENTORY_DATE,yyyy-MM-dd),
KUNNR,MATNR HAVING count(*) > 1;

c_row c_base%rowtype;

BEGIN

FOR c_row in c_base loop
        DELETE FROM STOCK_BASE_DATA WHERE INVENTORY_DATE = c_row.IDATE and KUNNR = c_row.KUNNR and MATNR = c_row.MATNR;
end loop;
COMMIT;
END;

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。