-- Customer specific once-script NYBU21.sql

SET ECHO ON
SPOOL xNYBU21.lst
SET DEFINE OFF

-- NYBU#31082 functie former tenant omhangen naar kenmerk former tenant
-- Functie former tenant (=key 10752 wordt kenmerk former tenant (=key 1220)
DECLARE
   CURSOR c
   IS
      SELECT   prs_perslid_key
        FROM   prs_perslid
       WHERE   prs_srtperslid_key = 10752
               AND prs_perslid_key NOT IN
                        (SELECT   prs_link_key
                           FROM   prs_kenmerklink
                          WHERE   prs_kenmerk_key = 1220
                                  AND prs_kenmerklink_waarde = 1);
BEGIN
   FOR rec IN c
   LOOP
      BEGIN
         INSERT INTO prs_kenmerklink (prs_link_key,
                                      prs_kenmerklink_niveau,
                                      prs_kenmerk_key,
                                      prs_kenmerklink_waarde,
                                      prs_kenmerklink_aanmaak)
           VALUES   (rec.prs_perslid_key,
                     'P',
                     1220,
                     1,
                     SYSDATE);

         UPDATE   prs_perslid
            SET   prs_srtperslid_key = 1537
          WHERE   prs_perslid_key = rec.prs_perslid_key;
      END;
   END LOOP;

   COMMIT;
END;
/

BEGIN adm.systrackscriptId('$Id$'); END;
/
COMMIT;

SPOOL OFF
@nybu.sql