Step 1) connect opera user by using Sqldeveloper or sqlplus
begin
pms_p.initialize('NA_REPORTS','NA_REPORTS','XXXXX');
end;
Step 2) Create backup:
create table room_repairs_backup_
Step 3) Delete wrong rows:
delete from room_repairs where resort = pms_p.resort and ( completed_date is not null or end_date < pms_p.business_date)
Step 4) Confirm above change:
commit
Step 5) Check in the ROOM_REPAIRS table if there are duplicate for the same room.
Once this is done for each property, check the remaining records and make sure there are no duplicate entries, ie. multiple entries for the same room number with overlapping dates and different status.
To check duplicate entries may use :
--select * from room_repairs where resort = pms_p.resort order by room , begin_date
if you find anything run below
-----------------------------------------------------------------
If you can't delete the row using the script at step 2), then try the following:
Step 3b)
DELETE from room_repairs rr
where rr.resort = pms_p.resort
AND ( completed_date is not null or end_date < pms_p.business_date )
AND EXISTS (SELECT 'X' FROM room r WHERE r.room = rr.room AND r.resort = rr.resort)
Step 4b)
commit