Sample PL/SQL script for cleaning a detail table referring a master table
March 13, 2013
Have you ever had a need to write a PL/SQL snippet to clean a table. If you are in need, here is one below – Here is a sample PL/SQL code to delete old data from a detail table which is older than 120 days.
declare
fi index_items.file_r%type;
cursor get_file_r is
select file_r from master_items where source=’WINWIN’ and date_r begin
for get_file_r_Rec in get_file_r
loop
fi := get_file_r_Rec.file_r;
delete from index_items where file_r=fi;
end loop;
end;
/
commit
/