
// CF 7-17

// Incumbents table

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

// Actual modifications

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

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

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

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

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

