
// CF 7-15

// Incumbents table

CREATE TABLE Incumbents (
                        SSN             integer,
                        PCN             integer,
                        StartDate       date,
                        EndDate         date,
                        PRIMARY KEY (SSN, PCN)
                        );

// Actual modifications

INSERT INTO Incumbents 
   SELECT SSN,
          PCN,
          DATE '01/01/1998',
          EndDate
     FROM Incumbents
    WHERE SSN = 111223333
      AND PCN = 341288
      AND StartDate <= DATE '01/01/1997'
      AND EndDate > DATE '01/01/1998';

UPDATE Incumbents
   SET EndDate = DATE '01/01/1997'
 WHERE SSN = 111223333
   AND PCN = 341288
   AND StartDate < DATE '01/01/1997'
   AND EndDate >= DATE '01/01/1997';

UPDATE Incumbents
   SET StartDate = DATE '01/01/1998'
 WHERE SSN = 111223333
   AND PCN = 341288
   AND StartDate < DATE '01/01/1997'
   AND EndDate >= DATE '01/01/1998';

DELETE
  FROM Incumbents
 WHERE SSN = 111223333
   AND PCN = 341288
   AND StartDate >= DATE '01/01/1997'
   AND EndDate > DATE '01/01/1998';

