-- Sequenced update recording that Pere actually purchased the flat
-- on January 12
INSERT INTO Prop_Owner
SELECT customer_number, property_number, VT_Begin, 
       TO_DATE( '01/12/1998', 'MM/DD/YYYY' ), SYSDATE, 
       TO_DATE( '12/31/9999', 'MM/DD/YYYY' )
FROM Prop_Owner
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

INSERT INTO Prop_Owner
SELECT customer_number, property_number, 
       TO_DATE( '01/15/1998', 'MM/DD/YYYY' ), VT_End, 
       SYSDATE, TO_DATE( '12/31/9999', 'MM/DD/YYYY' )
FROM Prop_Owner
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

INSERT INTO Prop_Owner
SELECT 145, property_number, VT_Begin, VT_End,
       SYSDATE, TO_DATE( '12/31/9999', 'MM/DD/YYYY' )
FROM Prop_Owner
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

UPDATE Prop_Owner
SET TT_Stop = SYSDATE
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01-15/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

INSERT INTO Prop_Owner
SELECT customer_number, property_number, 
       TO_DATE( '01/12/1998', 'MM/DD/YYYY' ), VT_End,
       SYSDATE, TO_DATE( '12/31/9999', 'MM/DD/YYYY' )
FROM Prop_Owner
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

UPDATE Prop_Owner
SET TT_Stop = SYSDATE
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/12/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

INSERT INTO Prop_Owner
SELECT customer_number, property_number, 
       VT_Begin, TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
       SYSDATE, TO_DATE( '12/31/9999', 'MM/DD/YYYY' )
FROM Prop_Owner
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND TT_Stop = TO_DATE( '12/31/9999', 'MM/DD/YYYY' );

UPDATE Prop_Owner
SET TT_Stop = SYSDATE
WHERE property_number = 7797 AND customer_number <> 145
  AND VT_Begin < TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND VT_End > TO_DATE( '01/15/1998', 'MM/DD/YYYY' )
  AND TT_Stop =TO_DATE( '12/31/9999', 'MM/DD/YYYY' ); 

