218 lines
7.2 KiB
SQL
218 lines
7.2 KiB
SQL
--
|
|
-- $Id$
|
|
--
|
|
-- Script containing customer specific sql statements for the ASPN database
|
|
|
|
DEFINE thisfile = 'ASPN.SQL'
|
|
DEFINE dbuser = 'ASPN'
|
|
|
|
SET ECHO ON
|
|
SET DEFINE ON
|
|
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
|
|
COLUMN fcltcusttxt NEW_VALUE fcltcusttxt NOPRINT;
|
|
WHENEVER SQLERROR CONTINUE;
|
|
SELECT adm.getscriptspoolfile('&thisfile') AS fcltlogfile FROM DUAL;
|
|
SPOOL &fcltlogfile
|
|
WHENEVER SQLERROR EXIT;
|
|
SELECT adm.checkscriptcust('&dbuser') AS fcltcusttxt FROM DUAL;
|
|
WHENEVER SQLERROR CONTINUE;
|
|
---------------------------------------
|
|
PROMPT &fcltcusttxt
|
|
---------------------------------------
|
|
SET DEFINE OFF
|
|
|
|
------ payload begin ------
|
|
|
|
--
|
|
-- Personen import
|
|
--
|
|
|
|
CREATE OR REPLACE PROCEDURE aspn_import_perslid (p_import_key IN NUMBER)
|
|
AS
|
|
oracle_err_num NUMBER;
|
|
oracle_err_mes VARCHAR2 (200);
|
|
v_errormsg VARCHAR2 (400);
|
|
v_errorhint VARCHAR2 (400);
|
|
v_newline FAC_IMP_FILE.FAC_IMP_FILE_LINE%TYPE;
|
|
BEGIN
|
|
|
|
BEGIN
|
|
SELECT fac_imp_file_line
|
|
INTO v_newline
|
|
FROM fac_imp_file
|
|
WHERE fac_import_key = p_import_key
|
|
AND fac_imp_file_index = 1;
|
|
|
|
IF v_newline LIKE
|
|
CHR (TO_NUMBER ('EF', 'xx'))
|
|
|| CHR (TO_NUMBER ('BB', 'xx'))
|
|
|| CHR (TO_NUMBER ('BF', 'xx'))
|
|
|| '%'
|
|
THEN
|
|
-- EF BB BF aangetroffen
|
|
fac.imp_writelog (p_import_key,
|
|
'W',
|
|
'Byte Order Mark aangetroffen',
|
|
'Bestand heeft onbehandeld UTF-8 formaat.'
|
|
);
|
|
v_newline := SUBSTR (v_newline, 4);
|
|
END IF;
|
|
|
|
-- Verwijder de dubbele quotes
|
|
v_newline := REPLACE (v_newline, '"');
|
|
|
|
UPDATE fac_imp_file
|
|
SET fac_imp_file_line = v_newline
|
|
WHERE fac_import_key = p_import_key
|
|
AND fac_imp_file_index = 1;
|
|
|
|
|
|
EXCEPTION WHEN OTHERS
|
|
THEN
|
|
fac.imp_writelog (p_import_key,
|
|
'E',
|
|
'Fout bij controle op Byte Order Mark',
|
|
''
|
|
);
|
|
END;
|
|
|
|
|
|
v_errorhint := 'Generieke update';
|
|
-- de sequence array staat beschreven in PRS_PAC.SRC bij de prs.import_perslid proc
|
|
prs.import_perslid (p_import_key,
|
|
'0;0;0;0;0;0;7;4;0;3;' ||
|
|
'0;0;0;0;0;10;11;6;0;8;' ||
|
|
'9;0;0;0;0;0;0;0;0;0;'||
|
|
'0;0;0;0;0;0;0;0;0;0;'||
|
|
'0;0;0;0;0;0',
|
|
'S.No;SAM Account Name;First Name;Last Name;Display Name;Email Address;Department;Employee Number;Title;Telephone Number;Mobile%'
|
|
);
|
|
|
|
UPDATE fac_imp_perslid
|
|
SET prs_afdeling_naam = REGEXP_SUBSTR (prs_afdeling_naam,
|
|
'[[:digit:]]{1,}',
|
|
1,
|
|
1,
|
|
'i');
|
|
|
|
COMMIT;
|
|
EXCEPTION
|
|
WHEN OTHERS
|
|
THEN
|
|
oracle_err_num := SQLCODE;
|
|
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
|
|
v_errormsg := 'Error ' || oracle_err_num || '/' || oracle_err_mes;
|
|
fac.imp_writelog (p_import_key, 'E', v_errormsg, v_errorhint);
|
|
END aspn_import_perslid;
|
|
/
|
|
|
|
CREATE OR REPLACE PROCEDURE aspn_update_perslid (
|
|
p_import_key IN NUMBER
|
|
) IS
|
|
-- Alle personen verwijderen die niet meer in import bestand voorkomen.
|
|
CURSOR c_del
|
|
IS
|
|
SELECT p.prs_perslid_key, p.prs_perslid_oslogin, pf.prs_perslid_naam_full
|
|
FROM fac_imp_perslid i, prs_perslid p, prs_v_perslid_fullnames_all pf
|
|
WHERE UPPER (p.prs_perslid_oslogin) = UPPER (i.prs_perslid_oslogin(+))
|
|
AND pf.prs_perslid_key = p.prs_perslid_key
|
|
AND p.prs_perslid_oslogin IS NOT NULL
|
|
AND i.prs_perslid_oslogin IS NULL
|
|
AND p.prs_perslid_verwijder IS NULL
|
|
AND substr(p.prs_perslid_oslogin, 1, 1) != '_'
|
|
ORDER BY 2;
|
|
|
|
v_count NUMBER;
|
|
|
|
BEGIN
|
|
-- generic update
|
|
|
|
SELECT count(*)
|
|
INTO v_count
|
|
FROM fac_imp_perslid;
|
|
|
|
IF v_count < 150
|
|
THEN
|
|
fac.imp_writelog (p_import_key,
|
|
'E',
|
|
'Het aantal te importeren personen is te klein ('
|
|
|| TO_CHAR (v_count) || ')',
|
|
'Zie Specificatie'
|
|
);
|
|
RETURN;
|
|
END IF;
|
|
|
|
-- 'LOGIN' betekent dat op basis van oslogin wordt gematched.
|
|
-- 'A' betekent altijd alle (andere/overige) werkplekken verwijderen
|
|
prs.update_perslid (p_import_key, 'LOGIN', NULL);
|
|
|
|
-- Verwijder personen die niet meer in de import voorkomen.
|
|
FOR rec IN c_del
|
|
LOOP
|
|
BEGIN
|
|
prs.delete_perslid (p_import_key, rec.prs_perslid_key);
|
|
END;
|
|
END LOOP;
|
|
|
|
END aspn_update_perslid;
|
|
/
|
|
|
|
CREATE OR REPLACE VIEW aspn_v_ins_qrc_mld
|
|
AS
|
|
SELECT i.ins_deel_omschrijving hide_f_sort,
|
|
l.alg_locatie_code||' '||l.alg_locatie_omschrijving fclt_f_locatie,
|
|
o.alg_gebouw_omschrijving fclt_f_gebouw,
|
|
o.alg_plaatsaanduiding fclt_f_plaats,
|
|
d.ins_discipline_omschrijving fclt_f_discipline,
|
|
g.ins_srtgroep_omschrijving fclt_f_objectgroep,
|
|
s.ins_srtdeel_omschrijving fclt_f_objectsoort,
|
|
i.ins_deel_omschrijving fclt_f_identificatie,
|
|
d.ins_discipline_omschrijving||' / '||sm.mld_stdmelding_omschrijving fclt_f_melding,
|
|
i.ins_deel_key,
|
|
s.ins_srtdeel_key,
|
|
o.alg_gebouw_code,
|
|
o.alg_verdieping_code,
|
|
i.ins_discipline_key fclt_3d_discipline_key,
|
|
l.alg_locatie_key fclt_3d_locatie_key,
|
|
i.ins_alg_ruimte_type,
|
|
i.ins_alg_ruimte_key,
|
|
b.fac_bookmark_id hide_f_bookmark_id
|
|
FROM ins_deel i,
|
|
ins_v_alg_overzicht o,
|
|
ins_srtdeel s,
|
|
ins_srtgroep g,
|
|
ins_discipline d,
|
|
alg_locatie l,
|
|
fac_bookmark b,
|
|
mld_stdmelding sm,
|
|
mld_stdmelding_srtinst si
|
|
WHERE b.fac_bookmark_naam = 'QRC_MELDING'
|
|
AND (b.fac_bookmark_expire IS NULL OR b.fac_bookmark_expire > SYSDATE)
|
|
AND ins_deel_verwijder IS NULL
|
|
AND i.ins_deel_module = 'INS'
|
|
AND i.ins_deel_parent_key IS NULL
|
|
AND s.ins_srtdeel_key = i.ins_srtdeel_key
|
|
AND g.ins_srtgroep_key = s.ins_srtgroep_key
|
|
AND d.ins_discipline_key = g.ins_discipline_key
|
|
AND o.alg_onroerendgoed_keys = i.ins_alg_ruimte_key
|
|
AND o.alg_onroerendgoed_type = i.ins_alg_ruimte_type
|
|
AND i.ins_alg_ruimte_type IN ('T', 'R', 'W')
|
|
AND o.alg_locatie_key = i.ins_alg_locatie_key
|
|
AND i.ins_alg_locatie_key = l.alg_locatie_key
|
|
AND sm.mld_stdmelding_key = si.mld_stdmelding_key
|
|
AND si.ins_srtinstallatie_key = DECODE(si.ins_srtinstallatie_niveau,
|
|
'S', i.ins_srtdeel_key,
|
|
'G', s.ins_srtgroep_key,
|
|
'D', g.ins_discipline_key);
|
|
|
|
------ payload end ------
|
|
|
|
SET DEFINE OFF
|
|
BEGIN adm.systrackscriptId ('$Id$', 0); END;
|
|
/
|
|
|
|
COMMIT;
|
|
SET ECHO OFF
|
|
SPOOL OFF
|
|
SET DEFINE ON
|
|
PROMPT Logfile of this upgrade is: &fcltlogfile |