UPDATE cnt_contract
   SET cnt_contract_status = NULL
 WHERE cnt_contract_key IN
             (SELECT cnt_contract_key
                FROM cnt_contract c, prs_bedrijfadres ba
               WHERE NOT EXISTS
                        (SELECT fac_tracking_refkey
                           FROM fac_tracking
                          WHERE fac_srtnotificatie_key = 406
                            AND fac_tracking_refkey = cnt_contract_key)
                 AND cnt_contract_looptijd_tot > SYSDATE
                 AND cnt_contract_status = 0
                 AND cnt_prs_bedrijf_key = ba.prs_bedrijf_key
                 AND ba.prs_bedrijfadres_type = 'O');


DECLARE
   CURSOR c
   IS
      SELECT cnt_contract_key, cnt_contract_kosten
        FROM cnt_contract c, prs_bedrijfadres ba
       WHERE NOT EXISTS
                (SELECT fac_tracking_refkey
                   FROM fac_tracking
                  WHERE fac_srtnotificatie_key = 406
                    AND fac_tracking_refkey = cnt_contract_key)
         AND cnt_contract_looptijd_tot > SYSDATE
         AND cnt_contract_status IS NULL
         AND cnt_prs_bedrijf_key = ba.prs_bedrijf_key
         AND ba.prs_bedrijfadres_type = 'O';
BEGIN
   FOR rec IN c
   LOOP
      BEGIN
         cnt.setcontractstatus (rec.cnt_contract_key, 2, NULL);
      END;
   END LOOP;

   COMMIT;
END;