FMHN#71214 Dubbele personen verwijderen, eerste versie
svn path=/Customer/; revision=55070
This commit is contained in:
81
onces/FMHN/FMHN#71214.sql
Normal file
81
onces/FMHN/FMHN#71214.sql
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Formatted on 22/2/2022 12:20:03 (QP5 v5.371) */
|
||||
--
|
||||
-- $Id$
|
||||
--
|
||||
-- De IDM broker heeft onbedoeld personen dubbel aangeleverd.
|
||||
-- Het zijn nogal wat records (18000+), dus daarom via een once.
|
||||
-- De laatste toegevoegde (obv emailadres) moet worden verwijderd.
|
||||
-- Oftewel, 1 emailadres die 4 keer voorkomt, moet de laatste prs_perslid_key behouden, rest mag weg (leegmaken)
|
||||
|
||||
|
||||
DEFINE thisfile = 'FMHN#71214.sql'
|
||||
DEFINE dbuser = '^FMHN'
|
||||
|
||||
SET ECHO ON
|
||||
SET DEFINE ON
|
||||
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
|
||||
COLUMN fcltcusterr NEW_VALUE fcltcusterr NOPRINT;
|
||||
WHENEVER SQLERROR CONTINUE;
|
||||
|
||||
SELECT adm.getscriptspoolfile ('&thisfile') AS fcltlogfile FROM DUAL;
|
||||
|
||||
SPOOL &fcltlogfile
|
||||
WHENEVER SQLERROR EXIT;
|
||||
|
||||
SELECT adm.checkscriptcust ('&dbuser') AS fcltcusterr FROM DUAL;
|
||||
|
||||
WHENEVER SQLERROR CONTINUE;
|
||||
PROMPT &fcltcusterr
|
||||
SET DEFINE OFF
|
||||
|
||||
------ payload begin ------
|
||||
|
||||
DECLARE
|
||||
CURSOR c IS
|
||||
SELECT p.prs_perslid_key,
|
||||
p.prs_perslid_email,
|
||||
p.prs_perslid_externid,
|
||||
p.prs_perslid_externsyncdate
|
||||
FROM prs_perslid p
|
||||
WHERE SUBSTR (prs_perslid_externid, 0, 2) = '03'
|
||||
AND p.prs_perslid_verwijder IS NULL
|
||||
AND p.prs_perslid_email IS NOT NULL
|
||||
-- AND UPPER (p.prs_perslid_email) = 'MARJA.BREUKEL@MINIENW.NL'
|
||||
AND p.prs_perslid_key NOT IN
|
||||
(SELECT MIN (x.prs_perslid_key)
|
||||
FROM prs_perslid x
|
||||
WHERE x.prs_perslid_email = p.prs_perslid_email
|
||||
AND x.prs_perslid_verwijder IS NULL)
|
||||
AND p.prs_perslid_key NOT IN -- Mogelijk al verplichtingen op deze records, dus uitsluiten, eerst omhangen
|
||||
(SELECT t.prs_perslid_key
|
||||
FROM fac_tracking t
|
||||
WHERE t.prs_perslid_key = p.prs_perslid_key)
|
||||
ORDER BY p.prs_perslid_key DESC;
|
||||
BEGIN
|
||||
FOR rec IN c
|
||||
LOOP
|
||||
BEGIN
|
||||
UPDATE prs_perslid p
|
||||
SET p.prs_perslid_verwijder = SYSDATE
|
||||
WHERE p.prs_perslid_email = rec.prs_perslid_key;
|
||||
END;
|
||||
END LOOP;
|
||||
END;
|
||||
/
|
||||
|
||||
------ payload end ------
|
||||
|
||||
SET DEFINE OFF
|
||||
|
||||
BEGIN
|
||||
adm.systrackscriptId (
|
||||
'$Id$',
|
||||
1);
|
||||
END;
|
||||
/
|
||||
|
||||
COMMIT;
|
||||
SET ECHO OFF
|
||||
SPOOL OFF
|
||||
SET DEFINE ON
|
||||
PROMPT Logfile of this upgrade is: &fcltlogfile
|
||||
Reference in New Issue
Block a user