CREATE OR REPLACE TRIGGER PCCT0A_INS 
AFTER INSERT ON PCCP0A
FOR EACH ROW
DECLARE
   R NUMBER := 99;
BEGIN
  DELETE FROM PCCP0A01 WHERE PNR = :NEW.PNR;
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Personnr', ' ', :NEW.PNR, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Namn', ' ', :NEW.NAMN, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Adress', ' ', :NEW.ADRESS, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Postnr', ' ', :NEW.POSTNR, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Ort', ' ', :NEW.ORT, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Medborgarskap', ' ', :NEW.MEDBSKAP, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Medborgarskap datum', ' ', :NEW.MEDBDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Nyckelkod', ' ', :NEW.NYCKKOD, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Hemkommun', ' ', :NEW.FOLKKOM, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Födelsekommun', ' ', :NEW.FODKOM, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Boendekommun', ' ', :NEW.BOKOM, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Avregorsak', ' ', :NEW.AVREGORS, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Avregdatum', ' ', :NEW.AVREGDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Adresskydd', ' ', :NEW.ADRSKYDD, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Modersmål', ' ', :NEW.MODMAL, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Födelsedatum', ' ', :NEW.FODDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Kön', ' ', :NEW.KON, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE)
  VALUES (:NEW.PNR, 'Yrke', ' ', :NEW.YRKE, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');  
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE)
  VALUES (:NEW.PNR, 'Utlandsadress', ' ', :NEW.UTL_ADR, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Utlandspostadr', ' ', :NEW.UTL_POSTADR, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Utlandsadr land', ' ', :NEW.UTL_ADRLAND, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Tidigare kommun', ' ', :NEW.TIDKOMM, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Avlidendatum', ' ', :NEW.AVLDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Civilstånd', ' ', :NEW.CIVKOD, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Civilståndsdatum', ' ', :NEW.CIVDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Adressdatum', ' ', :NEW.ADRESSDAT, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');   
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'Mobil', ' ', :NEW.MOBIL, :NEW.UPDDAT, :NEW.UPDSIGN, ' ');
  INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
  VALUES (:NEW.PNR, 'E-post hem', ' ', :NEW.EPOSTHEM, :NEW.UPDDAT, :NEW.UPDSIGN, ' '); 
END;
/;

CREATE OR REPLACE TRIGGER PCCT0A_UPD
AFTER UPDATE ON PCCP0A
FOR EACH ROW
DECLARE
   R NUMBER := 99;
BEGIN
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Personnr';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Personnr', ' ', :OLD.PNR, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Namn';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Namn', ' ', :OLD.NAMN, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Adress';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Adress', ' ', :OLD.ADRESS, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Postnr';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Postnr', ' ', :OLD.POSTNR, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Ort';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Ort', ' ', :OLD.ORT, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Medborgarskap';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Medborgarskap', ' ', :OLD.MEDBSKAP, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Medborgarskap datum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Medborgarskap datum', ' ', :OLD.MEDBDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Nyckelkod';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Nyckelkod', ' ', :OLD.NYCKKOD, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Hemkommun';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Hemkommun', ' ', :OLD.FOLKKOM, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Födelsekommun';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Födelsekommun', ' ', :OLD.FODKOM, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Boendekommun';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Boendekommun', ' ', :OLD.BOKOM, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Avregorsak';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Avregorsak', ' ', :OLD.AVREGORS, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Avregdatum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Avregdatum', ' ', :OLD.AVREGDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Adresskydd';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Adresskydd', ' ', :OLD.ADRSKYDD, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Modersmål';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Modersmål', ' ', :OLD.MODMAL, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Födelsedatum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Födelsedatum', ' ', :OLD.FODDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Kön';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Kön', ' ', :OLD.KON, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Yrke';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE)
   VALUES (:OLD.PNR, 'Yrke', ' ', :OLD.YRKE, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');  
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Utlandsadress';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE)
   VALUES (:OLD.PNR, 'Utlandsadress', ' ', :OLD.UTL_ADR, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');  
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Utlandspostadr';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Utlandspostadr', ' ', :OLD.UTL_POSTADR, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Utlandsadr land';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Utlandsadr land', ' ', :OLD.UTL_ADRLAND, :OLD.UPDDAT, :OLD.UPDSIGN, ' '); 
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Tidigare kommun';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Tidigare kommun', ' ', :OLD.TIDKOMM, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Avlidendatum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Avlidendatum', ' ', :OLD.AVLDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Civilstånd';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Civilstånd', ' ', :OLD.CIVKOD, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Civilståndsdatum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Civilståndsdatum', ' ', :OLD.CIVDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Adressdatum';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Adressdatum', ' ', :OLD.ADRESSDAT, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');   
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'Mobil';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'Mobil', ' ', :OLD.MOBIL, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF;
  SELECT COUNT(*) INTO R FROM PCCP0A01 WHERE PNR = :OLD.PNR AND COLNAME = 'E-post hem';
  IF (R = 0) THEN
   INSERT INTO PCCP0A01 (PNR, COLNAME, OLDVALUE, NEWVALUE, UPDDAT, UPDSIGN, DATASOURCE) 
   VALUES (:OLD.PNR, 'E-post hem', ' ', :OLD.EPOSTHEM, :OLD.UPDDAT, :OLD.UPDSIGN, ' ');
  END IF; 
  IF :OLD.PNR<>:NEW.PNR THEN
    DELETE FROM PCCP0A01 WHERE PNR = :NEW.PNR;

    UPDATE PCCP0A01 SET 
    PNR = :NEW.PNR 
    WHERE PNR = :OLD.PNR;

    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.PNR, 
    NEWVALUE=:NEW.PNR, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' ' 
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Personnr';
  END IF;
  IF :OLD.NAMN<>:NEW.NAMN THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.NAMN, 
    NEWVALUE=:NEW.NAMN, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Namn';
  END IF;
  IF :OLD.ADRESS<>:NEW.ADRESS THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.ADRESS, 
    NEWVALUE=:NEW.ADRESS, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Adress';
  END IF;
  IF :OLD.POSTNR<>:NEW.POSTNR THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.POSTNR, 
    NEWVALUE=:NEW.POSTNR, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Postnr';
  END IF;
  IF :OLD.ORT<>:NEW.ORT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.ORT, 
    NEWVALUE=:NEW.ORT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Ort';
  END IF;
  IF :OLD.MEDBSKAP<>:NEW.MEDBSKAP THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.MEDBSKAP, 
    NEWVALUE=:NEW.MEDBSKAP, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Medborgarskap';
  END IF;
  IF :OLD.MEDBDAT<>:NEW.MEDBDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.MEDBDAT, 
    NEWVALUE=:NEW.MEDBDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Medborgarskap datum';
  END IF;
  IF :OLD.NYCKKOD<>:NEW.NYCKKOD THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.NYCKKOD, 
    NEWVALUE=:NEW.NYCKKOD, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Nyckelkod';
  END IF;
  IF :OLD.FOLKKOM<>:NEW.FOLKKOM THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.FOLKKOM, 
    NEWVALUE=:NEW.FOLKKOM, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Hemkommun';
  END IF;
  IF :OLD.FODKOM<>:NEW.FODKOM THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.FODKOM, 
    NEWVALUE=:NEW.FODKOM, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Födelsekommun';
  END IF;
  IF :OLD.BOKOM<>:NEW.BOKOM THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.BOKOM, 
    NEWVALUE=:NEW.BOKOM, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Boendekommun';
  END IF;
  IF :OLD.AVREGORS<>:NEW.AVREGORS THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.AVREGORS, 
    NEWVALUE=:NEW.AVREGORS, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Avregorsak';
  END IF;
  IF :OLD.AVREGDAT<>:NEW.AVREGDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.AVREGDAT, 
    NEWVALUE=:NEW.AVREGDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Avregdatum';
  END IF;
  IF :OLD.ADRSKYDD<>:NEW.ADRSKYDD THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.ADRSKYDD, 
    NEWVALUE=:NEW.ADRSKYDD, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Adresskydd';
  END IF;
  IF :OLD.MODMAL<>:NEW.MODMAL THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.MODMAL, 
    NEWVALUE=:NEW.MODMAL, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Modersmål';
  END IF;
  IF :OLD.FODDAT<>:NEW.FODDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.FODDAT, 
    NEWVALUE=:NEW.FODDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Födelsedatum';
  END IF;
  IF :OLD.KON<>:NEW.KON THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.KON, 
    NEWVALUE=:NEW.KON, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Kön';
  END IF;
  IF :OLD.YRKE<>:NEW.YRKE THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.YRKE, 
    NEWVALUE=:NEW.YRKE, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Yrke';
  END IF;
  IF :OLD.UTL_ADR<>:NEW.UTL_ADR THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.UTL_ADR, 
    NEWVALUE=:NEW.UTL_ADR, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Utlandsadress';
  END IF;
  IF :OLD.UTL_POSTADR<>:NEW.UTL_POSTADR THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.UTL_POSTADR, 
    NEWVALUE=:NEW.UTL_POSTADR, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Utlandspostadr';
  END IF;
  IF :OLD.UTL_ADRLAND<>:NEW.UTL_ADRLAND THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.UTL_ADRLAND, 
    NEWVALUE=:NEW.UTL_ADRLAND, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Utlandsadr land';
  END IF;
  IF :OLD.TIDKOMM<>:NEW.TIDKOMM THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.TIDKOMM, 
    NEWVALUE=:NEW.TIDKOMM, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Tidigare kommun';
  END IF;
  IF :OLD.AVLDAT<>:NEW.AVLDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.AVLDAT, 
    NEWVALUE=:NEW.AVLDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Avlidendatum';
  END IF;
  IF :OLD.CIVKOD<>:NEW.CIVKOD THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.CIVKOD, 
    NEWVALUE=:NEW.CIVKOD, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Civilstånd';
  END IF;
  IF :OLD.CIVDAT<>:NEW.CIVDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.CIVDAT, 
    NEWVALUE=:NEW.CIVDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Civilståndsdatum';
  END IF;
  IF :OLD.ADRESSDAT<>:NEW.ADRESSDAT THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.ADRESSDAT, 
    NEWVALUE=:NEW.ADRESSDAT, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Adressdatum';
  END IF;
  IF :OLD.MOBIL<>:NEW.MOBIL THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.MOBIL, 
    NEWVALUE=:NEW.MOBIL, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'Mobil';
  END IF;
  IF :OLD.EPOSTHEM<>:NEW.EPOSTHEM THEN
    UPDATE PCCP0A01 SET 
    OLDVALUE=:OLD.EPOSTHEM, 
    NEWVALUE=:NEW.EPOSTHEM, 
    UPDDAT=:NEW.UPDDAT, 
    UPDSIGN= :NEW.UPDSIGN,
    DATASOURCE = ' '  
    WHERE PNR = :NEW.PNR AND 
    COLNAME = 'E-post hem';
  END IF;  
END;
/;