Correcties n.a.v. DB15
svn path=/Customer/trunk/; revision=15157
This commit is contained in:
823
CSUN/CSUN.sql
823
CSUN/CSUN.sql
@@ -1,7 +1,7 @@
|
||||
-- Script containing customer specific configuration sql statements for CSUN: CSU National Accounts
|
||||
-- (c) 2011 SG|facilitor
|
||||
-- $Revision: 2 $
|
||||
-- $Modtime: 29-02-12 13:04 $
|
||||
-- $Revision: 3 $
|
||||
-- $Modtime: 9-03-12 14:48 $
|
||||
--
|
||||
-- Support: +31 53 4800710
|
||||
|
||||
@@ -455,8 +455,7 @@ EXCEPTION
|
||||
'errormsg',
|
||||
'Database fout - Neem contact op met uw systeembeheerder ' || errormsg);
|
||||
|
||||
fac.imp_writelog ('PROCESSEMAIL',
|
||||
to_char(sysdate, 'yyyymmdd hh24mi'),
|
||||
fac.writelog ('PROCESSEMAIL',
|
||||
'E',
|
||||
'OTHERS (error ' || SQLCODE || '/' || SUBSTR (SQLERRM, 1, 100) || ')',
|
||||
errormsg || ' afzender:' || pfrom);
|
||||
@@ -597,7 +596,821 @@ AS
|
||||
AND d.alg_regio_key = r.alg_regio_key;
|
||||
|
||||
|
||||
BEGIN fac.registercustversion('CSUN', 2); END;
|
||||
CREATE OR REPLACE PROCEDURE csun_import_onrgoed (p_import_key IN NUMBER,
|
||||
p_filedir IN VARCHAR2,
|
||||
p_filename IN VARCHAR2
|
||||
)
|
||||
AS
|
||||
c_fielddelimitor VARCHAR2 (1) := ';';
|
||||
v_newline VARCHAR2 (1000); -- Input line
|
||||
v_errormsg VARCHAR2 (1000);
|
||||
oracle_err_num NUMBER;
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
header_is_valid NUMBER;
|
||||
v_count NUMBER;
|
||||
v_ongeldig NUMBER (1);
|
||||
v_mode NUMBER (1);
|
||||
v_aanduiding VARCHAR2 (200);
|
||||
-- De importvelden:
|
||||
v_regio_omschrijving VARCHAR2 (255); -- 30
|
||||
v_district_omschrijving VARCHAR2 (255); -- 30
|
||||
v_locatie_code VARCHAR2 (255); -- 10
|
||||
v_locatie_omschrijving VARCHAR2 (255); -- 30
|
||||
v_gebouw_code VARCHAR2 (255); -- 10
|
||||
v_gebouw_naam VARCHAR2 (255); -- 30
|
||||
v_srtgebouw_omschrijving VARCHAR2 (255); -- 30
|
||||
v_locatie_verantw VARCHAR2 (255); -- 30
|
||||
v_locatie_verantw_tel VARCHAR2 (255); -- 15
|
||||
v_locatie_adres VARCHAR2 (255); -- 35
|
||||
v_locatie_postcode VARCHAR2 (255); -- 12
|
||||
v_locatie_plaats VARCHAR2 (255); -- 30
|
||||
v_locatie_land VARCHAR2 (255); -- 30
|
||||
v_locatie_post_adres VARCHAR2 (255); -- 35
|
||||
v_locatie_post_postcode VARCHAR2 (255); -- 12
|
||||
v_locatie_post_plaats VARCHAR2 (255); -- 30
|
||||
v_locatie_post_land VARCHAR2 (255); -- 30
|
||||
v_kenmerk1 VARCHAR2(255);
|
||||
v_kenmerk2 VARCHAR2(255);
|
||||
v_kenmerk3 VARCHAR2(255);
|
||||
v_kenmerk4 VARCHAR2(255);
|
||||
v_kenmerk5 VARCHAR2(255);
|
||||
v_kenmerk6 VARCHAR2(255);
|
||||
v_kenmerk7 VARCHAR2(255);
|
||||
v_kenmerk8 VARCHAR2(255);
|
||||
v_kenmerk9 VARCHAR2(255);
|
||||
v_kenmerk10 VARCHAR2(255);
|
||||
CURSOR c1
|
||||
IS
|
||||
SELECT *
|
||||
FROM fac_imp_file
|
||||
WHERE fac_import_key = p_import_key
|
||||
ORDER BY fac_imp_file_index;
|
||||
BEGIN
|
||||
-- Eerst opruiming
|
||||
DELETE FROM imp_log
|
||||
WHERE fac_import_key = p_import_key;
|
||||
DELETE FROM fac_imp_onrgoed1;
|
||||
header_is_valid := 0;
|
||||
v_count := 0;
|
||||
COMMIT;
|
||||
FOR rec1 IN c1
|
||||
LOOP
|
||||
BEGIN
|
||||
v_errormsg := 'Fout FETCH te importeren rij';
|
||||
v_newline := rec1.fac_imp_file_line;
|
||||
v_errormsg := 'Fout opvragen te importeren rij';
|
||||
v_aanduiding := '';
|
||||
v_ongeldig := 0;
|
||||
-- Lees alle veldwaarden
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_regio_omschrijving);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_district_omschrijving);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_code);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_omschrijving);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_gebouw_code);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_gebouw_naam);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_srtgebouw_omschrijving);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_verantw);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_verantw_tel);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_adres);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_postcode);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_plaats);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_land);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_post_adres);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_post_postcode);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_post_plaats);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_locatie_post_land);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk1);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk2);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk3);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk4);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk5);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk6);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk7);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk8);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk9);
|
||||
fac.imp_getfield (v_newline, c_fielddelimitor, v_kenmerk10);
|
||||
v_aanduiding := v_locatie_code || '|' || v_gebouw_code || '| ';
|
||||
IF (header_is_valid = 0)
|
||||
THEN
|
||||
IF UPPER (v_regio_omschrijving) = 'REGIO OMSCHRIJVING'
|
||||
AND UPPER (v_gebouw_code) = 'GEBOUWCODE'
|
||||
AND UPPER (v_locatie_post_land) = 'LAND'
|
||||
THEN
|
||||
header_is_valid := 1;
|
||||
END IF;
|
||||
ELSE
|
||||
v_count := v_count + 1;
|
||||
-- Controleer alle veldwaarde
|
||||
IF LENGTH (v_regio_omschrijving) > 30
|
||||
THEN
|
||||
v_regio_omschrijving := SUBSTR (v_regio_omschrijving, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'District-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_regio_omschrijving || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_district_omschrijving) > 30
|
||||
THEN
|
||||
v_district_omschrijving := SUBSTR (v_district_omschrijving, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'District-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_district_omschrijving || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_code) > 10
|
||||
THEN
|
||||
v_locatie_code := SUBSTR (v_locatie_code, 1, 10);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Locatiecode-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_code || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_omschrijving) > 50
|
||||
THEN
|
||||
v_locatie_omschrijving := SUBSTR (v_locatie_omschrijving, 1, 50);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Locatie-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_omschrijving || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_gebouw_code) > 12
|
||||
THEN
|
||||
v_gebouw_code := SUBSTR (v_gebouw_code, 1, 12);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Gebouwcode-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_gebouw_code || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_gebouw_naam) > 30
|
||||
THEN
|
||||
v_gebouw_naam := SUBSTR (v_gebouw_naam, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Gebouw-aanduiding is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_gebouw_naam || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_srtgebouw_omschrijving) > 30
|
||||
THEN
|
||||
v_srtgebouw_omschrijving := SUBSTR (v_srtgebouw_omschrijving, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Functie-aanduiding gebouw is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_srtgebouw_omschrijving || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_verantw) > 30
|
||||
THEN
|
||||
v_locatie_verantw := SUBSTR (v_locatie_verantw, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Locatie-aanduiding contactpersoon is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_verantw || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_verantw_tel) > 15
|
||||
THEN
|
||||
v_locatie_verantw_tel := SUBSTR (v_locatie_verantw_tel, 1, 15);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Telefoon-aanduiding verantwoordelijke locatie is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_verantw_tel || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_adres) > 35
|
||||
THEN
|
||||
v_locatie_adres := SUBSTR (v_locatie_adres, 1, 35);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Locatie-aanduiding bezoek-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_adres || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_postcode) > 12
|
||||
THEN
|
||||
v_locatie_postcode := SUBSTR (v_locatie_postcode, 1, 12);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Postcode-aanduiding bezoek-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_postcode || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_plaats) > 30
|
||||
THEN
|
||||
v_locatie_plaats := SUBSTR (v_locatie_plaats, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Plaats-aanduiding bezoek-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_plaats || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_land) > 30
|
||||
THEN
|
||||
v_locatie_land := SUBSTR (v_locatie_land, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Land-aanduiding bezoek-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_land || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_post_adres) > 35
|
||||
THEN
|
||||
v_locatie_post_adres := SUBSTR (v_locatie_post_adres, 1, 35);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Adres-aanduiding post-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_post_adres || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_post_postcode) > 12
|
||||
THEN
|
||||
v_locatie_post_postcode := SUBSTR (v_locatie_post_postcode, 1, 12);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Postcode-aanduiding post-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_post_postcode || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_post_plaats) > 30
|
||||
THEN
|
||||
v_locatie_post_plaats := SUBSTR (v_locatie_post_plaats, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Plaats-aanduiding post-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_post_plaats || '>'
|
||||
);
|
||||
END IF;
|
||||
--
|
||||
IF LENGTH (v_locatie_post_land) > 30
|
||||
THEN
|
||||
v_locatie_post_land := SUBSTR (v_locatie_post_land, 1, 30);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
v_aanduiding || 'Land-aanduiding post-adres is te lang',
|
||||
'Aanduiding wordt afgebroken tot <' || v_locatie_post_land || '>'
|
||||
);
|
||||
END IF;
|
||||
-- Insert geformatteerde import record
|
||||
IF v_ongeldig = 0
|
||||
THEN
|
||||
v_errormsg := 'Fout bij toevoegen te impoteren gebouw [' || v_gebouw_code || ']';
|
||||
INSERT INTO fac_imp_onrgoed1 (
|
||||
alg_regio_omschrijving,
|
||||
alg_district_omschrijving,
|
||||
alg_locatie_code,
|
||||
alg_locatie_omschrijving,
|
||||
alg_gebouw_code,
|
||||
alg_gebouw_naam,
|
||||
alg_srtgebouw_omschrijving,
|
||||
alg_locatie_verantw,
|
||||
alg_locatie_verantw_tel,
|
||||
alg_locatie_adres,
|
||||
alg_locatie_postcode,
|
||||
alg_locatie_plaats,
|
||||
alg_locatie_land,
|
||||
alg_locatie_post_adres,
|
||||
alg_locatie_post_postcode,
|
||||
alg_locatie_post_plaats,
|
||||
alg_locatie_post_land,
|
||||
kenmerk1,
|
||||
kenmerk2,
|
||||
kenmerk3,
|
||||
kenmerk4,
|
||||
kenmerk5,
|
||||
kenmerk6,
|
||||
kenmerk7,
|
||||
kenmerk8,
|
||||
kenmerk9,
|
||||
kenmerk10
|
||||
)
|
||||
VALUES (
|
||||
v_regio_omschrijving,
|
||||
v_district_omschrijving,
|
||||
v_locatie_code,
|
||||
v_locatie_omschrijving,
|
||||
v_gebouw_code,
|
||||
v_gebouw_naam,
|
||||
v_srtgebouw_omschrijving,
|
||||
v_locatie_verantw,
|
||||
v_locatie_verantw_tel,
|
||||
v_locatie_adres,
|
||||
v_locatie_postcode,
|
||||
v_locatie_plaats,
|
||||
v_locatie_land,
|
||||
v_locatie_post_adres,
|
||||
v_locatie_post_postcode,
|
||||
v_locatie_post_plaats,
|
||||
v_locatie_post_land,
|
||||
v_kenmerk1,
|
||||
v_kenmerk2,
|
||||
v_kenmerk3,
|
||||
v_kenmerk4,
|
||||
v_kenmerk5,
|
||||
v_kenmerk6,
|
||||
v_kenmerk7,
|
||||
v_kenmerk8,
|
||||
v_kenmerk9,
|
||||
v_kenmerk10
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
END LOOP;
|
||||
IF (header_is_valid = 0)
|
||||
THEN
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding || 'Ongeldig importbestand',
|
||||
'Geen geldige headerregel aanwezig'
|
||||
);
|
||||
ELSE
|
||||
fac.imp_writelog (p_import_key, 'S', 'Gebouwen: aantal ingelezen regels: ' || TO_CHAR (v_count), '');
|
||||
END IF;
|
||||
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, '');
|
||||
END csun_import_onrgoed;
|
||||
/
|
||||
|
||||
CREATE OR REPLACE PROCEDURE csun_update_onrgoed (
|
||||
p_import_key IN NUMBER
|
||||
) IS
|
||||
c_fielddelimitor VARCHAR2 (1) := ';';
|
||||
v_newline VARCHAR2 (1000); -- Input line
|
||||
v_errormsg VARCHAR2 (1000);
|
||||
v_errorhint VARCHAR2 (1000);
|
||||
oracle_err_num NUMBER;
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
v_aanduiding VARCHAR2 (200);
|
||||
v_count NUMBER(10);
|
||||
v_ongeldig NUMBER(1);
|
||||
v_count_update NUMBER(10);
|
||||
v_count_tot NUMBER(10);
|
||||
-- De importvelden:
|
||||
v_regio_omschrijving VARCHAR2(255); -- 30
|
||||
v_district_omschrijving VARCHAR2(255); -- 30
|
||||
v_locatie_code VARCHAR2(255); -- 10
|
||||
v_locatie_omschrijving VARCHAR2(255); -- 30
|
||||
v_gebouw_code VARCHAR2(255); -- 12
|
||||
v_gebouw_naam VARCHAR2(255); -- 30
|
||||
v_srtgebouw_omschrijving VARCHAR2(255); -- 30
|
||||
v_locatie_verantw VARCHAR2(255); -- 30
|
||||
v_locatie_verantw_tel VARCHAR2(255); -- 15
|
||||
v_locatie_adres VARCHAR2(255); -- 35
|
||||
v_locatie_postcode VARCHAR2(255); -- 12
|
||||
v_locatie_plaats VARCHAR2(255); -- 30
|
||||
v_locatie_land VARCHAR2(255); -- 30
|
||||
v_locatie_post_adres VARCHAR2(255); -- 35
|
||||
v_locatie_post_postcode VARCHAR2(255); -- 12
|
||||
v_locatie_post_plaats VARCHAR2(255); -- 30
|
||||
v_locatie_post_land VARCHAR2(255); -- 30
|
||||
v_regio_key NUMBER(10);
|
||||
v_district_key NUMBER(10);
|
||||
v_locatie_key NUMBER(10);
|
||||
v_srtgebouw_key NUMBER(10);
|
||||
v_gebouw_key NUMBER(10);
|
||||
v_verdieping_key NUMBER(10);
|
||||
v_ruimte_key NUMBER(10);
|
||||
CURSOR cRegio
|
||||
IS
|
||||
SELECT min(alg_regio_omschrijving) alg_regio_omschrijving
|
||||
FROM fac_imp_onrgoed1
|
||||
GROUP BY upper(alg_regio_omschrijving);
|
||||
recRegio cRegio%ROWTYPE;
|
||||
CURSOR cDistrict
|
||||
IS
|
||||
SELECT min(alg_district_omschrijving) alg_district_omschrijving, min(alg_regio_omschrijving) alg_regio_omschrijving
|
||||
FROM fac_imp_onrgoed1
|
||||
GROUP BY upper(alg_district_omschrijving);
|
||||
recDistrict cDistrict%ROWTYPE;
|
||||
CURSOR cLocatie
|
||||
IS
|
||||
SELECT
|
||||
min(ALG_LOCATIE_CODE) ALG_LOCATIE_CODE
|
||||
,min(ALG_LOCATIE_OMSCHRIJVING) ALG_LOCATIE_OMSCHRIJVING
|
||||
,min(ALG_LOCATIE_VERANTW) ALG_LOCATIE_VERANTW
|
||||
,min(ALG_LOCATIE_VERANTW_TEL) ALG_LOCATIE_VERANTW_TEL
|
||||
,min(ALG_LOCATIE_ADRES) ALG_LOCATIE_ADRES
|
||||
,min(ALG_LOCATIE_POSTCODE) ALG_LOCATIE_POSTCODE
|
||||
,min(ALG_LOCATIE_PLAATS) ALG_LOCATIE_PLAATS
|
||||
,min(ALG_LOCATIE_LAND) ALG_LOCATIE_LAND
|
||||
,min(ALG_LOCATIE_POST_ADRES) ALG_LOCATIE_POST_ADRES
|
||||
,min(ALG_LOCATIE_POST_POSTCODE) ALG_LOCATIE_POST_POSTCODE
|
||||
,min(ALG_LOCATIE_POST_PLAATS) ALG_LOCATIE_POST_PLAATS
|
||||
,min(ALG_LOCATIE_POST_LAND) ALG_LOCATIE_POST_LAND
|
||||
,min(ALG_DISTRICT_OMSCHRIJVING) ALG_DISTRICT_OMSCHRIJVING
|
||||
FROM fac_imp_onrgoed1
|
||||
GROUP BY upper(alg_locatie_code),upper(alg_locatie_omschrijving);
|
||||
recLocatie cLocatie%ROWTYPE;
|
||||
CURSOR cSrtGebouw
|
||||
IS
|
||||
SELECT min(alg_srtgebouw_omschrijving) alg_srtgebouw_omschrijving
|
||||
FROM fac_imp_onrgoed1
|
||||
WHERE alg_srtgebouw_omschrijving IS NOT NULL
|
||||
group by upper(alg_srtgebouw_omschrijving);
|
||||
recSrtGebouw cSrtGebouw%rowtype;
|
||||
CURSOR cGebouw
|
||||
IS
|
||||
SELECT min(ALG_GEBOUW_NAAM) ALG_GEBOUW_OMSCHRIJVING
|
||||
,min(ALG_LOCATIE_CODE) ALG_LOCATIE_CODE
|
||||
,min(ALG_LOCATIE_OMSCHRIJVING) ALG_LOCATIE_OMSCHRIJVING
|
||||
,min(ALG_GEBOUW_CODE) ALG_GEBOUW_CODE
|
||||
,min(ALG_SRTGEBOUW_OMSCHRIJVING) ALG_SRTGEBOUW_OMSCHRIJVING
|
||||
FROM fac_imp_onrgoed1
|
||||
GROUP BY upper(ALG_LOCATIE_CODE),upper(alg_locatie_omschrijving),upper(alg_gebouw_naam);
|
||||
recGebouw cGebouw%rowtype;
|
||||
BEGIN
|
||||
DELETE imp_log
|
||||
WHERE fac_import_key = p_import_key;
|
||||
-- ***********
|
||||
-- ***REGIO***
|
||||
-- ***********
|
||||
OPEN cRegio;
|
||||
v_count_update := 0;
|
||||
v_count_tot := 0;
|
||||
IF cRegio%ISOPEN THEN
|
||||
LOOP
|
||||
BEGIN
|
||||
v_aanduiding := recRegio.ALG_REGIO_OMSCHRIJVING||'| ';
|
||||
v_errormsg := '';
|
||||
v_errorhint := '';
|
||||
FETCH cRegio INTO recRegio;
|
||||
EXIT WHEN cRegio%NOTFOUND;
|
||||
v_count_tot := v_count_tot + 1;
|
||||
SELECT count(*)
|
||||
INTO v_count
|
||||
FROM alg_regio
|
||||
WHERE upper(ALG_REGIO_UPPER) = upper(recRegio.ALG_REGIO_OMSCHRIJVING)
|
||||
AND alg_regio_verwijder is null;
|
||||
IF (v_count = 0) THEN
|
||||
v_errorhint := 'Kan regio niet toevoegen';
|
||||
insert into ALG_REGIO
|
||||
(ALG_REGIO_OMSCHRIJVING
|
||||
)
|
||||
values
|
||||
(recRegio.ALG_REGIO_OMSCHRIJVING
|
||||
);
|
||||
END IF;
|
||||
commit;
|
||||
v_count_update := v_count_update + 1;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR(SQLERRM, 1, 200);
|
||||
IF (v_errormsg = '') THEN
|
||||
v_errormsg := 'Fout tijdens verwerken van regio ['||recRegio.ALG_REGIO_OMSCHRIJVING||']';
|
||||
END IF;
|
||||
v_errorhint := v_errorhint||': ' || oracle_err_mes;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding||v_errormsg,
|
||||
v_errorhint
|
||||
);
|
||||
commit; -- tbv logging
|
||||
END;
|
||||
END LOOP;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Regio: verwerkte regels zonder foutmelding: '||to_char(v_count_update),
|
||||
''
|
||||
);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Regio: verwerkte regels met foutmelding: '||to_char(v_count_tot-v_count_update),
|
||||
''
|
||||
);
|
||||
END IF;
|
||||
-- **************
|
||||
-- ***DISTRICT***
|
||||
-- **************
|
||||
OPEN cDistrict;
|
||||
IF cDistrict%ISOPEN THEN
|
||||
v_count_update := 0;
|
||||
v_count_tot := 0;
|
||||
LOOP
|
||||
BEGIN
|
||||
v_aanduiding := recRegio.ALG_REGIO_OMSCHRIJVING||'|'||recDistrict.ALG_DISTRICT_OMSCHRIJVING||'| ';
|
||||
v_errormsg := '';
|
||||
v_errorhint := '';
|
||||
FETCH cDistrict INTO recDistrict;
|
||||
EXIT WHEN cDistrict%NOTFOUND;
|
||||
v_count_tot := v_count_tot + 1;
|
||||
v_errorhint := 'Kan geen regio bij district vinden';
|
||||
SELECT alg_regio_key
|
||||
INTO v_regio_key
|
||||
FROM alg_regio
|
||||
WHERE upper(alg_regio_upper) = upper(recDistrict.alg_regio_omschrijving)
|
||||
AND alg_regio_verwijder is null;
|
||||
SELECT count(*)
|
||||
INTO v_count
|
||||
FROM alg_district
|
||||
WHERE upper(ALG_DISTRICT_UPPER) = upper(recDistrict.ALG_DISTRICT_OMSCHRIJVING)
|
||||
AND alg_district_verwijder is null;
|
||||
IF (v_count = 0) THEN
|
||||
v_errorhint := 'Kan district niet toevoegen';
|
||||
insert into ALG_DISTRICT
|
||||
(ALG_REGIO_KEY
|
||||
,ALG_DISTRICT_OMSCHRIJVING
|
||||
)
|
||||
values
|
||||
(v_regio_key
|
||||
,recDistrict.ALG_DISTRICT_OMSCHRIJVING
|
||||
);
|
||||
END IF;
|
||||
commit;
|
||||
v_count_update := v_count_update + 1;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR(SQLERRM, 1, 200);
|
||||
IF (v_errormsg = '') THEN
|
||||
v_errormsg := 'Fout tijdens verwerken van district <'||recDistrict.ALG_DISTRICT_OMSCHRIJVING||'>';
|
||||
END IF;
|
||||
v_errorhint := v_errorhint||': ' || oracle_err_mes;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding||v_errormsg,
|
||||
v_errorhint
|
||||
);
|
||||
commit; -- tbv logging
|
||||
END;
|
||||
END LOOP;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'District: verwerkte regels zonder foutmelding: '||to_char(v_count_update),
|
||||
''
|
||||
);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'District: verwerkte regels met foutmelding: '||to_char(v_count_tot-v_count_update),
|
||||
''
|
||||
);
|
||||
END IF;
|
||||
CLOSE cDistrict;
|
||||
-- **************
|
||||
-- ***LOCATIE****
|
||||
-- **************
|
||||
OPEN cLocatie;
|
||||
IF cLocatie%ISOPEN THEN
|
||||
v_count_update := 0;
|
||||
v_count_tot := 0;
|
||||
LOOP
|
||||
BEGIN
|
||||
v_aanduiding := recLocatie.ALG_DISTRICT_OMSCHRIJVING||'|'||recLocatie.ALG_LOCATIE_CODE||'| ';
|
||||
v_errormsg := '';
|
||||
v_errorhint := '';
|
||||
FETCH cLocatie INTO recLocatie;
|
||||
EXIT WHEN cLocatie%NOTFOUND;
|
||||
v_count_tot := v_count_tot + 1;
|
||||
v_errorhint := 'Kan geen district vinden met districtomschrijving ['||recLocatie.alg_district_omschrijving||']';
|
||||
SELECT alg_district_key
|
||||
INTO v_district_key
|
||||
FROM alg_district
|
||||
WHERE alg_district_upper = upper(recLocatie.alg_district_omschrijving)
|
||||
AND alg_district_verwijder is null;
|
||||
SELECT count(*)
|
||||
INTO v_count
|
||||
FROM alg_locatie
|
||||
WHERE upper(ALG_LOCATIE_CODE) = upper(recLocatie.ALG_LOCATIE_CODE)
|
||||
AND upper(ALG_LOCATIE_OMSCHRIJVING) = upper(recLocatie.ALG_LOCATIE_OMSCHRIJVING)
|
||||
AND alg_locatie_verwijder is null;
|
||||
IF (v_count = 0) THEN
|
||||
v_errorhint := 'Kan locatie niet toevoegen';
|
||||
insert into ALG_LOCATIE
|
||||
(ALG_DISTRICT_KEY
|
||||
,ALG_LOCATIE_CODE
|
||||
,ALG_LOCATIE_OMSCHRIJVING
|
||||
,ALG_LOCATIE_VERANTW
|
||||
,ALG_LOCATIE_VERANTW_TEL
|
||||
,ALG_LOCATIE_ADRES
|
||||
,ALG_LOCATIE_POSTCODE
|
||||
,ALG_LOCATIE_PLAATS
|
||||
,ALG_LOCATIE_LAND
|
||||
,ALG_LOCATIE_POST_ADRES
|
||||
,ALG_LOCATIE_POST_POSTCODE
|
||||
,ALG_LOCATIE_POST_PLAATS
|
||||
,ALG_LOCATIE_POST_LAND
|
||||
)
|
||||
values
|
||||
(v_district_key
|
||||
,recLocatie.ALG_LOCATIE_CODE
|
||||
,recLocatie.ALG_LOCATIE_OMSCHRIJVING
|
||||
,recLocatie.ALG_LOCATIE_VERANTW
|
||||
,recLocatie.ALG_LOCATIE_VERANTW_TEL
|
||||
,recLocatie.ALG_LOCATIE_ADRES
|
||||
,recLocatie.ALG_LOCATIE_POSTCODE
|
||||
,recLocatie.ALG_LOCATIE_PLAATS
|
||||
,recLocatie.ALG_LOCATIE_LAND
|
||||
,recLocatie.ALG_LOCATIE_POST_ADRES
|
||||
,recLocatie.ALG_LOCATIE_POST_POSTCODE
|
||||
,recLocatie.ALG_LOCATIE_POST_PLAATS
|
||||
,recLocatie.ALG_LOCATIE_POST_LAND
|
||||
);
|
||||
END IF;
|
||||
commit;
|
||||
v_count_update := v_count_update + 1;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR(SQLERRM, 1, 200);
|
||||
v_errormsg := 'Fout tijdens verwerken van locatie ['||recLocatie.ALG_LOCATIE_CODE||'/'||recLocatie.ALG_LOCATIE_OMSCHRIJVING||']';
|
||||
v_errorhint := v_errorhint||': ' || oracle_err_mes;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding||v_errormsg,
|
||||
v_errorhint
|
||||
);
|
||||
commit; -- tbv logging
|
||||
END;
|
||||
END LOOP;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Locatie: verwerkte regels zonder foutmelding: '||to_char(v_count_update),
|
||||
''
|
||||
);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Locatie: verwerkte regels met foutmelding: '||to_char(v_count_tot-v_count_update),
|
||||
''
|
||||
);
|
||||
END IF;
|
||||
CLOSE cLocatie;
|
||||
-- ********************
|
||||
-- ***GEBOUWFUNCTIE****
|
||||
-- ********************
|
||||
OPEN cSrtGebouw;
|
||||
IF cSrtGebouw%ISOPEN THEN
|
||||
v_count_update := 0;
|
||||
v_count_tot := 0;
|
||||
LOOP
|
||||
BEGIN
|
||||
v_aanduiding := recSrtGebouw.ALG_SRTGEBOUW_OMSCHRIJVING||'| ';
|
||||
v_errormsg := '';
|
||||
v_errorhint := '';
|
||||
FETCH cSrtGebouw INTO recSrtGebouw;
|
||||
EXIT WHEN cSrtGebouw%NOTFOUND;
|
||||
v_count_tot := v_count_tot + 1;
|
||||
SELECT count(*)
|
||||
INTO v_count
|
||||
FROM alg_srtgebouw
|
||||
WHERE upper(ALG_SRTGEBOUW_OMSCHRIJVING) = upper(recSrtGebouw.ALG_SRTGEBOUW_OMSCHRIJVING)
|
||||
AND alg_srtgebouw_verwijder is null;
|
||||
IF (v_count = 0) THEN
|
||||
v_errorhint := 'Kan gebouwfunctie niet toevoegen';
|
||||
insert into ALG_SRTGEBOUW
|
||||
(ALG_SRTGEBOUW_OMSCHRIJVING
|
||||
)
|
||||
values
|
||||
(recSrtGebouw.ALG_SRTGEBOUW_OMSCHRIJVING
|
||||
);
|
||||
END IF;
|
||||
commit;
|
||||
v_count_update := v_count_update + 1;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR(SQLERRM, 1, 200);
|
||||
IF (v_errormsg = '') THEN
|
||||
v_errormsg := 'Fout tijdens verwerken van gebouwfunctie ['||recSrtGebouw.ALG_srtgebouw_omschrijving||']';
|
||||
END IF;
|
||||
v_errorhint := v_errorhint||': ' || oracle_err_mes;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding||v_errormsg,
|
||||
v_errorhint
|
||||
);
|
||||
commit; -- tbv logging
|
||||
END;
|
||||
END LOOP;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Gebouwfunctie: verwerkte regels zonder foutmelding: '||to_char(v_count_update),
|
||||
''
|
||||
);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Gebouwfunctie: verwerkte regels met foutmelding: '||to_char(v_count_tot-v_count_update),
|
||||
''
|
||||
);
|
||||
END IF;
|
||||
CLOSE cSrtGebouw;
|
||||
-- ************
|
||||
-- ***GEBOUW***
|
||||
-- ************
|
||||
OPEN cGebouw;
|
||||
IF cGebouw%ISOPEN THEN
|
||||
v_count_update := 0;
|
||||
v_count_tot := 0;
|
||||
LOOP
|
||||
BEGIN
|
||||
v_aanduiding := recGebouw.ALG_LOCATIE_CODE||'|'||recGebouw.ALG_GEBOUW_CODE||'| ';
|
||||
v_errormsg := '';
|
||||
v_errorhint := '';
|
||||
FETCH cGebouw INTO recGebouw;
|
||||
EXIT WHEN cGebouw%NOTFOUND;
|
||||
v_count_tot := v_count_tot + 1;
|
||||
BEGIN
|
||||
v_errorhint := ' Kan locatie ['||recGebouw.ALG_LOCATIE_CODE||'/'||recGebouw.ALG_LOCATIE_OMSCHRIJVING||'] niet vinden';
|
||||
SELECT ALG_LOCATIE_KEY
|
||||
INTO v_locatie_key
|
||||
FROM ALG_LOCATIE
|
||||
WHERE UPPER(ALG_LOCATIE_CODE) = UPPER(recGebouw.ALG_LOCATIE_CODE)
|
||||
AND UPPER(ALG_LOCATIE_OMSCHRIJVING) = UPPER(recGebouw.ALG_LOCATIE_OMSCHRIJVING)
|
||||
AND alg_locatie_verwijder is null;
|
||||
v_errorhint := ' Kan gebouwfunctie ['||recGebouw.ALG_SRTGEBOUW_OMSCHRIJVING||'] niet vinden';
|
||||
SELECT ALG_SRTGEBOUW_KEY
|
||||
INTO v_srtgebouw_key
|
||||
FROM ALG_SRTGEBOUW
|
||||
WHERE UPPER(ALG_SRTGEBOUW_UPPER) = UPPER(recGebouw.ALG_SRTGEBOUW_OMSCHRIJVING)
|
||||
AND alg_srtgebouw_verwijder is null;
|
||||
select count(*)
|
||||
into v_count
|
||||
from ALG_GEBOUW
|
||||
where ALG_LOCATIE_KEY = v_locatie_key
|
||||
and upper(ALG_GEBOUW_CODE) = upper(recGebouw.ALG_GEBOUW_CODE)
|
||||
and ALG_GEBOUW_verwijder is null;
|
||||
IF (v_count = 0) THEN
|
||||
v_errorhint := 'Fout bij toevoegen gebouw';
|
||||
insert into ALG_GEBOUW
|
||||
(ALG_LOCATIE_KEY
|
||||
,ALG_SRTGEBOUW_KEY
|
||||
,ALG_GEBOUW_CODE
|
||||
,ALG_GEBOUW_OMSCHRIJVING
|
||||
,ALG_GEBOUW_NAAM
|
||||
)
|
||||
values
|
||||
(v_locatie_key
|
||||
,v_srtgebouw_key
|
||||
,recGebouw.ALG_GEBOUW_CODE
|
||||
,recGebouw.ALG_GEBOUW_OMSCHRIJVING
|
||||
,recGebouw.ALG_GEBOUW_OMSCHRIJVING
|
||||
);
|
||||
v_count_update := v_count_update + 1;
|
||||
END IF;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR(SQLERRM, 1, 200);
|
||||
v_errormsg := 'Fout tijdens verwerken van gebouw ['||recGebouw.ALG_gebouw_omschrijving||'] '||v_errormsg;
|
||||
v_errormsg := v_errormsg||' (ORACLE error number = [' || ORACLE_err_num || '] ORACLE error message = [' || ORACLE_err_mes || '])';
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_aanduiding||v_errormsg,
|
||||
v_errorhint
|
||||
);
|
||||
commit; -- tbv logging
|
||||
END;
|
||||
commit;
|
||||
END;
|
||||
END LOOP;
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Gebouw: verwerkte regels zonder foutmelding: '||to_char(v_count_update),
|
||||
''
|
||||
);
|
||||
fac.imp_writelog (p_import_key,
|
||||
'S',
|
||||
'Gebouw: verwerkte regels met foutmelding: '||to_char(v_count_tot-v_count_update),
|
||||
''
|
||||
);
|
||||
END IF;
|
||||
CLOSE cGebouw;
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
v_errormsg := '(ORACLE error ' || oracle_err_mes || ')';
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
'Fout tijdens importeren van onroerend goed (locatie en gebouw) ',
|
||||
''
|
||||
);
|
||||
END csun_update_onrgoed;
|
||||
/
|
||||
|
||||
|
||||
|
||||
BEGIN fac.registercustversion('CSUN', 3); END;
|
||||
/
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user