Friday, September 11, 2009

DUPLICATE ROW DELETE

set serveroutput on;


CREATE OR REPLACE PROCEDURE dup_pro IS
v_rows_del NUMBER;
BEGIN
DELETE FROM s
WHERE ROWID NOT IN (SELECT MIN (ROWID)
FROM s
GROUP BY last_name);

v_rows_del := SQL%ROWCOUNT;
DBMS_OUTPUT.put_line (v_rows_del || ' rows deleted.');
END dup_pro;
/
show error;

exec dup_pro;

Select * from s;

No comments: