/* DB30TO31.SRC
 * Update script van FACILITOR schema
 * $Revision$
 * $Id$
 */
#include "prologue.inc"

COMMIT;

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39780
INSERT INTO fac_notificatie_job (fac_notificatie_job_view, fac_notificatie_job_oms, fac_notificatie_job_mode, fac_notificatie_job_interval, fac_notificatie_job_nextrun, fac_notificatie_job_flags)
     VALUES ('FAC_V_NOTI_LICENTIE', 'Notificatie bij afwijkende licenties.', 2, 2160, (select add_months (trunc(SYSDATE, 'Q') + 0, 4) + 3/4  from dual), 1);

DEF_FAC_SRTNOT('ADMLIC', 0, 'lcl_noti_ADMLIC', '', '0', null, 10);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#38888

CREATE UNIQUE INDEX fac_i_fac_api1 ON fac_api (fac_api_name);

CREATE UNIQUE INDEX fac_i_fac_session2 ON fac_session(fac_session_sessionid_hash);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39394

create index fac_i_fac_result1 on fac_result(fac_result_sessionid);

DROP INDEX fac_i_import_appkey1;
CREATE INDEX fac_i_import_appkey1 ON fac_import(fac_import_app_key, fac_import_key);

ALTER TABLE fac_import_app
    ADD fac_import_app_loglevel
    NUMBER(1) DEFAULT 0 NOT NULL;

/////////////////////////////////////////////////////////////////////////////////////////// AADS#38285
/////////////////////////////////////////////////////////////////////////////////////////// KFNS#38873

ALTER TABLE prs_bedrijfadres
  ADD alg_district_key NUMBER(10)
    DEFAULT NULL
    CONSTRAINT prs_r_alg_distr_key
    REFERENCES alg_district(alg_district_key) ON DELETE CASCADE;

ALTER TABLE prs_bedrijfadres
  ADD alg_locatie_key NUMBER(10)
    DEFAULT NULL
    CONSTRAINT prs_r_alg_loc_key
    REFERENCES alg_locatie(alg_locatie_key) ON DELETE CASCADE;

DROP INDEX prs_i_prs_bedrijfadres2;
CREATE UNIQUE INDEX prs_i_prs_bedrijfadres2 on prs_bedrijfadres(prs_bedrijf_key, prs_bedrijfadres_type, mld_typeopdr_key, alg_district_key, alg_locatie_key);

/////////////////////////////////////////////////////////////////////////////////////////// AAIT#33956
CREATE SEQUENCE fac_s_fac_audit_key MINVALUE 1;

CREATE_TABLE(fac_audit, 0)
(
   fac_audit_key
       NUMBER(10)
       CONSTRAINT fac_k_fac_audit_key PRIMARY KEY,
   fac_audit_tabelnaam
       VARCHAR2(30)
       CONSTRAINT fac_k_fac_audit_tabelnaam CHECK(fac_audit_tabelnaam IS NOT NULL),
   fac_audit_tabelkey
       NUMBER(10),
   fac_audit_veldnaam
       VARCHAR2(30),
   fac_audit_actie
       VARCHAR2(1)
       CONSTRAINT fac_k_fac_audit_actie CHECK(fac_audit_actie IN ('C', 'D', 'U')),
   fac_audit_waarde_oud
       VARCHAR2(4000),
   fac_audit_waarde_nieuw
       VARCHAR2(4000),
   prs_perslid_key
       NUMBER(10)
       CONSTRAINT fac_r_prs_perslid_key9 REFERENCES prs_perslid(prs_perslid_key) ON DELETE SET NULL,
   fac_audit_opmerking
       VARCHAR2(320),
   fac_audit_datum
       DATE
       DEFAULT SYSDATE
       CONSTRAINT fac_c_fac_audit_datum CHECK(fac_audit_datum IS NOT NULL)
);
CREATE INDEX fac_i_audit_perslidkey1 ON fac_audit(prs_perslid_key);
CREATE INDEX fac_i_audit_tabel1 ON fac_audit(fac_audit_tabelnaam, fac_audit_tabelkey);

ALTER TABLE fac_profielwaarde ADD fac_profielwaarde_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE fac_profiel ADD fac_profiel_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE fac_gebruikersgroep ADD fac_gebruikersgroep_aanmaak DATE DEFAULT SYSDATE;

-- FSN#40456 Ongeldige rechten verwijderen
DELETE
  FROM fac_groeprechten fr
 WHERE (fac_gebruiker_prs_level_read = 9 OR fac_gebruiker_alg_level_read = 9);

ALTER TABLE fac_groeprechten ADD fac_groeprechten_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE prs_kostenplaatsgrp ADD prs_kostenplaatsgrp_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE prs_kostenplaatsdisc ADD prs_kostenplaatsdisc_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE mld_stdmelding ADD mld_stdmelding_aanmaak DATE DEFAULT SYSDATE;
ALTER TABLE prs_perslidkostenplaats ADD prs_perslidkostenplaats_aanmk DATE DEFAULT SYSDATE;
ALTER TABLE prs_kostencombinatie ADD prs_kostencombinatie_aanmaak DATE DEFAULT SYSDATE;

/////////////////////////////////////////////////////////////////////////////////////////// FSN#32707
ALTER TABLE fac_imp_mld
  ADD ( mld_stdmelding_hint         VARCHAR2(1000)
      , mld_stdmelding_kopieerbaar  NUMBER(1)
      , mld_stdmelding_afmeldtext   NUMBER(1)
      , mld_stdmelding_doublecheck  NUMBER(4)
      , mld_stdmelding_slabewaken   NUMBER(1)
      );

/////////////////////////////////////////////////////////////////////////////////////////// AAVG#37310
ALTER TABLE fac_imp_ext_bedrijf
  ADD ( prs_relatietype  VARCHAR2(256)
      );


/////////////////////////////////////////////////////////////////////////////////////////// MDUX#38433
ALTER TABLE bes_disc_params ADD
      bes_disc_params_fiatflow
      NUMBER(1)
      DEFAULT 0
      CONSTRAINT bes_c_disc_params_fiatflow CHECK(bes_disc_params_fiatflow IN (0,1));


/////////////////////////////////////////////////////////////////////////////////////////// GRKL#38593
ALTER TABLE fac_imp_onrgoed2
  ADD res_discipline_expire_dagen NUMBER(3);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#38992
ALTER TABLE adm_tracking ADD (adm_tracking_key NUMBER(10));
CREATE SEQUENCE adm_s_adm_tracking_key START WITH 1;
UPDATE adm_tracking SET adm_tracking_key = adm_s_adm_tracking_key.NEXTVAL;
ALTER TABLE adm_tracking ADD CONSTRAINT adm_k_adm_tracking_key PRIMARY KEY (adm_tracking_key);

// Normaal hoeven trigger niet in de upgrade maar adm.systrackscriptId wordt nogal vaak aangeroepen
CREATE_TRIGGER(adm_t_adm_tracking_B_I)
BEFORE INSERT ON adm_tracking
FOR EACH ROW
BEGIN
    UPDATE_PRIMARY_KEY(adm_tracking_key, adm_s_adm_tracking_key);
END;
/
ALTER TABLE fac_bookmark DROP PRIMARY KEY DROP INDEX;
ALTER TABLE fac_bookmark ADD (fac_bookmark_key NUMBER(10));
CREATE SEQUENCE fac_s_fac_bookmark_key START WITH 1;
UPDATE fac_bookmark SET fac_bookmark_key = fac_s_fac_bookmark_key.NEXTVAL;
ALTER TABLE fac_bookmark ADD CONSTRAINT fac_k_fac_bookmark_key PRIMARY KEY (fac_bookmark_key);
CREATE UNIQUE INDEX fac_i_fac_bookmark1 ON fac_bookmark(fac_bookmark_id);

ALTER TABLE fac_qvw_ticket ADD (fac_qvw_ticket_key NUMBER(10));
CREATE SEQUENCE fac_s_fac_qvw_ticket_key START WITH 1;
UPDATE fac_qvw_ticket SET fac_qvw_ticket_key = fac_s_fac_qvw_ticket_key.NEXTVAL;
ALTER TABLE fac_qvw_ticket ADD CONSTRAINT fac_k_fac_qvw_ticket_key PRIMARY KEY (fac_qvw_ticket_key);

ALTER TABLE fac_session ADD (fac_session_key NUMBER(10));
CREATE SEQUENCE fac_s_fac_session_key START WITH 1;
UPDATE fac_session SET fac_session_key = fac_s_fac_session_key.NEXTVAL;
ALTER TABLE fac_session ADD CONSTRAINT fac_k_fac_session_key PRIMARY KEY (fac_session_key);

ALTER TABLE fac_sequence DROP PRIMARY KEY DROP INDEX;
ALTER TABLE fac_sequence MODIFY (fac_sequence_name VARCHAR2(50) NOT NULL);
ALTER TABLE fac_sequence ADD (fac_sequence_key NUMBER(10));
CREATE SEQUENCE fac_s_fac_sequence_key START WITH 1;
UPDATE fac_sequence SET fac_sequence_key = fac_s_fac_sequence_key.NEXTVAL;
ALTER TABLE fac_sequence ADD CONSTRAINT fac_k_fac_sequence_key PRIMARY KEY (fac_sequence_key);
CREATE UNIQUE INDEX fac_i_fac_sequence1 ON fac_sequence(fac_sequence_name);

/////////////////////////////////////////////////////////////////////////////////////////// MARX#39100
CREATE_TABLE(prs_bedrijf_bedrijf,0)
(
   prs_bedrijf_bedrijf_key
        NUMBER (10) PRIMARY KEY NOT NULL,
   prs_bedrijf_key1
        NUMBER (10)
        CONSTRAINT prs_r_prs_bedrijf_bedrijf1 REFERENCES prs_bedrijf (prs_bedrijf_key) NOT NULL,
   prs_bedrijf_externid1
        VARCHAR2(60),     -- optional remote key of 1
   prs_bedrijf_key2
        NUMBER (10)
        CONSTRAINT prs_r_prs_bedrijf_bedrijf2 REFERENCES prs_bedrijf (prs_bedrijf_key) NOT NULL,
   prs_bedrijf_externid2
        VARCHAR2(60),     -- optional remote key of 2
   prs_bedrijf_bedrijf_startdatum
        DATE
        DEFAULT SYSDATE,
   prs_bedrijf_bedrijf_einddatum
        DATE,
   prs_bedrijf_bedrijf_status
        NUMBER(1)         -- voor mld_opdr_teverzenden: 0=niet te verzenden 1=te verzenden
        DEFAULT(0)
        NOT NULL,
   prs_bedrijf_bedrijf_charged
        NUMBER(1)         -- 0=niemand, 1=opdrachtnemer, 2=opdrachtgever
        DEFAULT(0)
        NOT NULL,
   prs_bedrijf_bedrijf_chargemode
        NUMBER(4),        -- een codering voor de "premiummode" waaruit afgeleid kan worden hoe de kosten worden berekend (per opdracht, per bestelling, enz), enigszins futureproof
   prs_bedrijf_bedrijf_fee1
        NUMBER(6,2),      -- bedrag in euro's tbv berekening icm chargemode
   prs_bedrijf_bedrijf_fee2
        NUMBER(6,2),      -- bedrag in euro's tbv berekening icm chargemode
   prs_bedrijf_bedrijf_fee3
        NUMBER(6,2)       -- bedrag in euro's tbv berekening icm chargemode
);
CREATE SEQUENCE prs_s_prs_bedrijfbedrijf_key   MINVALUE 1;
CREATE_TRIGGER(prs_t_prs_bedrijfbedrijf_B_IU)
BEFORE INSERT OR UPDATE ON prs_bedrijf_bedrijf
FOR EACH ROW
BEGIN
    UPDATE_PRIMARY_KEY(prs_bedrijf_bedrijf_key, prs_s_prs_bedrijfbedrijf_key);
END;
/
CREATE UNIQUE INDEX prs_i_prs_bedrijfbedrijf1 ON prs_bedrijf_bedrijf(prs_bedrijf_key1, prs_bedrijf_key2);

DEF_MENUENTRY(2, 99140, 'lcl_menu_prs_bedrijf_bedrijf' , '', 'FAC', 'appl/mgt/prs_bedrijf_bedrijf.asp', 0, 0, 'WEB_PRSSYS');


/////////////////////////////////////////////////////////////////////////////////////////// FSN#39054
CREATE_TABLE(bgt_disc_params,0)
(
    bgt_disc_params_key
        NUMBER (10) PRIMARY KEY NOT NULL,
    bgt_ins_discipline_key
        NUMBER (10)
        CONSTRAINT bgt_r_ins_discipine_key REFERENCES ins_tab_discipline (ins_discipline_key),
    bgt_disc_params_code  -- projectcode
        VARCHAR2 (20 BYTE),
    bgt_disc_params_opdrachtgever
        VARCHAR2 (200 BYTE),
    bgt_disc_params_startdatum
        DATE
);

CREATE_TABLE(bgt_project, 0)
(
    bgt_project_key
        NUMBER (10) PRIMARY KEY NOT NULL,
    ins_discipline_key
        NUMBER (10)
        CONSTRAINT bgt_r_ins_discipline_key1 REFERENCES ins_tab_discipline (ins_discipline_key),
    bgt_project_code
        VARCHAR2 (20 BYTE),
    bgt_project_omschrijving
        VARCHAR2 (60 BYTE),
    bgt_project_volgnr
        NUMBER (3),
    bgt_project_prijspeildatum
        DATE,
    bgt_project_info
        VARCHAR2 (4000 BYTE),
    bgt_project_notes
        VARCHAR2 (4000 BYTE),
    bgt_project_aanmaak
        DATE DEFAULT SYSDATE,
    bgt_project_verwijder
        DATE
);

CREATE_TABLE(bgt_kostenrubriek,0)
(
    bgt_kostenrubriek_key
        NUMBER (10) PRIMARY KEY NOT NULL,
    bgt_project_key
        NUMBER (10)
        CONSTRAINT bgt_c_bgt_kostenrubriek1 NOT NULL
        CONSTRAINT bgt_r_bgt_project_key1 REFERENCES bgt_project (bgt_project_key),
    bgt_kostenrubriek_code
        VARCHAR2 (20 BYTE),
    bgt_kostenrubriek_oms
        VARCHAR2 (60 BYTE) NOT NULL
);

ALTER TABLE prs_kostensoortgrp ADD bgt_kostenrubriek_key CONSTRAINT prs_r_bgt_kostenrubriek_key1 REFERENCES bgt_kostenrubriek (bgt_kostenrubriek_key);

DROP INDEX prs_i_prs_kostensoort1;
CREATE UNIQUE INDEX prs_i_prs_kostensoort1 ON prs_kostensoort(prs_kostensoortgrp_key, prs_kostensoort_upper);

ALTER TABLE fin_factuurregel MODIFY ( fin_factuurregel_totaal NUMBER(12,2)
                                    , fin_factuurregel_btw NUMBER(14,4));

ALTER TABLE fin_factuur MODIFY ( fin_factuur_totaal NUMBER(12,2)
                               , fin_factuur_totaal_btw NUMBER(14,4)
                               , fin_factuur_gbedrag NUMBER(14,2) );

CREATE_TABLE(bgt_budget,0)
(
    bgt_budget_key
        NUMBER (10) PRIMARY KEY NOT NULL,
    ins_discipline_key
        NUMBER (10)
        CONSTRAINT prs_r_ins_discipline_key1 REFERENCES ins_tab_discipline (ins_discipline_key),
    bgt_project_key
        NUMBER (10)
        CONSTRAINT prs_r_bgt_project_key1 REFERENCES bgt_project (bgt_project_key),
    bgt_kostenrubriek_key
        NUMBER (10)
        CONSTRAINT prs_r_bgt_kostenrubriek_key2 REFERENCES bgt_kostenrubriek (bgt_kostenrubriek_key),
    prs_kostensoortgrp_key
        NUMBER (10)
        CONSTRAINT prs_r_kostensoortgrp_key2 REFERENCES prs_kostensoortgrp (prs_kostensoortgrp_key),
    prs_kostensoort_key
        NUMBER (10)
        CONSTRAINT prs_r_kostensoort_key2 REFERENCES prs_kostensoort (prs_kostensoort_key),
    prs_kostenplaatsgrp_key
        NUMBER (10)
        CONSTRAINT prs_r_kostenplaatsgrp_key3 REFERENCES prs_kostenplaatsgrp (prs_kostenplaatsgrp_key),
    prs_kostenplaats_key
        NUMBER (10)
        CONSTRAINT prs_r_kostenplaats_key5 REFERENCES prs_kostenplaats (prs_kostenplaats_key),
    bgt_budget_bedrag
        NUMBER (12,2),
    bgt_budget_btwbedrag
        NUMBER (12,2),
    bgt_budget_isreserve
        NUMBER(1)
        DEFAULT (0)
        NOT NULL
        CONSTRAINT bgt_c_bgt_budget_isreserve CHECK(bgt_budget_isreserve IN (0,1)),
    bgt_budget_begin
        DATE,
    bgt_budget_eind
        DATE,
    bgt_budget_aanmaak
        DATE DEFAULT SYSDATE,
    bgt_budget_vervaldatum
        DATE,
    CONSTRAINT bgt_c_bgt_budget1 CHECK (  (bgt_budget_isreserve = 0 AND (   bgt_kostenrubriek_key IS NOT NULL
                                                                        OR (bgt_kostenrubriek_key IS NOT NULL AND prs_kostensoortgrp_key IS NOT NULL)
                                                                        OR (bgt_kostenrubriek_key IS NOT NULL AND prs_kostensoortgrp_key IS NOT NULL AND prs_kostensoort_key IS NOT NULL)
                                                                        OR prs_kostenplaatsgrp_key IS NOT NULL
                                                                        OR (prs_kostenplaatsgrp_key IS NOT NULL AND prs_kostenplaats_key IS NOT NULL)
                                                                        )
                                          )
                                       OR (bgt_budget_isreserve = 1 AND prs_kostensoortgrp_key IS NULL AND prs_kostenplaats_key IS NULL)
                                       )
);

CREATE_TABLE(bgt_budgetmutatie, 1)
(
   bgt_budgetmutatie_key
        NUMBER (10) PRIMARY KEY,
   bgt_budgetmutatie_datum
        DATE NOT NULL,
   bgt_budgetmutatie_omschrijving
        VARCHAR2 (100) NOT NULL,
   prs_perslid_key
        NUMBER (10)
        NOT NULL
        CONSTRAINT bgt_r_prs_perslid_key2 REFERENCES prs_perslid (prs_perslid_key),
   bgt_budget_key_van
        NUMBER (10)
        CONSTRAINT bgt_r_bgt_budget1 REFERENCES bgt_budget (bgt_budget_key),
   bgt_budget_bedrag_van
        NUMBER (12, 2),
   bgt_budget_btwbedrag_van
        NUMBER (12, 2),
   bgt_budget_key_naar
        NUMBER (10)
        CONSTRAINT bgt_r_bgt_budget2 REFERENCES bgt_budget (bgt_budget_key),
   bgt_budget_bedrag_naar
        NUMBER (12, 2),
   bgt_budget_btwbedrag_naar
        NUMBER (12, 2),
   CONSTRAINT bgt_c_bgt_budget_key1 CHECK(bgt_budget_key_van IS NOT NULL OR bgt_budget_key_naar IS NOT NULL)
);

CREATE SEQUENCE bgt_s_bgt_disc_params_key   MINVALUE 1;
CREATE SEQUENCE bgt_s_bgt_project_key       MINVALUE 1;
CREATE SEQUENCE bgt_s_bgt_kostenrubriek_key MINVALUE 1;
CREATE SEQUENCE bgt_s_bgt_budget_key        MINVALUE 1;
CREATE SEQUENCE bgt_s_bgt_budgetmutatie_key MINVALUE 1;

ALTER TRIGGER mld_t_mld_opdr_B_IU DISABLE;
ALTER TABLE mld_opdr
  ADD ( prs_kostensoort_key
           NUMBER(10)
           CONSTRAINT mld_r_prs_kostensoort_key1 REFERENCES prs_kostensoort (prs_kostensoort_key),
        mld_opdr_kosten_btw
           NUMBER(12,2)
           DEFAULT 0,
        mld_opdr_meerwerk
           NUMBER(1)
           DEFAULT (0)
           CONSTRAINT mld_c_mld_opdr_meerwerk CHECK(mld_opdr_meerwerk IN (0, 1))
      );
ALTER TRIGGER mld_t_mld_opdr_B_IU ENABLE;

-- deze relatie is nu verplicht. Maak voor de ontbrekende verwijzingen een default aan.
ALTER TABLE prs_kostensoort DROP CONSTRAINT prs_r_prs_kostensoortgrp_key;
ALTER TABLE prs_kostensoort MODIFY (prs_kostensoortgrp_key CONSTRAINT prs_r_prs_kostensoortgrp_key REFERENCES prs_kostensoortgrp(prs_kostensoortgrp_key));
DECLARE
   gcnt   NUMBER;
   gkey   NUMBER (10);
BEGIN
   SELECT COUNT ( * )
     INTO gcnt
     FROM prs_kostensoort
    WHERE prs_kostensoortgrp_key IS NULL;

   IF gcnt > 0
   THEN
      INSERT INTO prs_kostensoortgrp (prs_kostensoortgrp_oms)
          VALUES ('Default')
       RETURNING prs_kostensoortgrp_key
            INTO gkey;

      UPDATE prs_kostensoort
         SET prs_kostensoortgrp_key = gkey
       WHERE prs_kostensoortgrp_key IS NULL;
   END IF;
END;
/
ALTER TABLE prs_kostensoort MODIFY prs_kostensoortgrp_key NOT NULL;
ALTER TABLE prs_kostensoort ADD fin_btwtabelwaarde_key NUMBER(10) CONSTRAINT prs_r_fin_btwtabelwaarde_key REFERENCES fin_btwtabelwaarde (fin_btwtabelwaarde_key);

ALTER TABLE prs_kostenplaats DROP CONSTRAINT prs_r_prs_kostenplaatsgrp_key;
ALTER TABLE prs_kostenplaats MODIFY (prs_kostenplaatsgrp_key CONSTRAINT prs_r_prs_kostenplaatsgrp_key REFERENCES prs_kostenplaatsgrp(prs_kostenplaatsgrp_key));
// DB31d: Removed code, toch prs_kostenplaatsgrp.prs_kostenplaatsgrp_key weer NULL toestaan

ALTER TABLE prs_kostenplaatsgrp ADD bgt_project_key NUMBER(10) CONSTRAINT prs_r_bgt_project_key2 REFERENCES bgt_project(bgt_project_key);

ALTER TABLE mld_opdr DROP CONSTRAINT mld_r_mld_melding_key3;
ALTER TABLE mld_opdr ADD
(
    CONSTRAINT mld_r_mld_melding_key3 CHECK(mld_melding_key IS NOT NULL OR cnt_contract_key IS NOT NULL OR prs_kostensoort_key IS NOT NULL)
);

_FAC_MODULE('BGT','lcl_module_BGT')
DEF_FAC_FUNCTIE3('WEB_BGTMGT', 'BGT',  3, 1,    1);
DEF_FAC_FUNCTIE3('WEB_BGTMAN', 'BGT',  3, 1,    1);
DEF_FAC_FUNCTIE3('WEB_BGTUSE', 'BGT',  3, 1,    1);
DEF_FAC_FUNCTIE3('WEB_BGTORD', 'BGT',  3, 1,    1);

MENU_INSKOP_AFTER('lcl_bgt', 'lcl_menu_fac_qlikview_res', 1, 4) ;
DEF_MENUITEM(1, 'lcl_menu_bgt_disciplines_1'   , '', 'BGT', 'appl/bgt/bgt_search.asp?mode=wrap&id={1}', 0, 1, 'WEB_BGTMAN', 'R', '1', '');
//DEF_MENUITEM(1, 'lcl_menu_bgt_budget'           , '', 'BGT', 'appl/bgt/bgt_budget.asp', 0, 0, 'WEB_BGTMAN', 'R', '1', '');  // TODO ws weg
DEF_MENUITEM(1, 'lcl_menu_bgt_disciplines'     , '', 'BGT', 'appl/bgt/bgt_discipline.asp', 0, 0, 'WEB_BGTMGT', 'W', '1', '');

MENU_INS_AFTERKOP('lcl_menu_bgt_disciplines_1', 'lcl_bgt', 2) ;
MENU_INS_AFTER( 'lcl_menu_bgt_disciplines', 'lcl_menu_bgt_disciplines_1', 2);


/////////////////////////////////////////////////////////////////////////////////////////// HCAS#38260

ALTER TABLE ins_deelsrtcontrole MODIFY (ins_deelsrtcontrole_opmerking VARCHAR(4000));

/////////////////////////////////////////////////////////////////////////////////////////// GOUD#37603
ALTER TABLE res_disc_params ADD res_disc_params_bonotify NUMBER(2) DEFAULT 0;
ALTER TABLE res_disc_params ADD CONSTRAINT res_c_bonotify CHECK (res_disc_params_bonotify IS NOT NULL);
DEF_FAC_SRTNOT('RES2BO', 0, 'lcl_noti_RES2BO', 'res/res_reservering.asp?rsv_ruimte_key=', '0', 'reservering', 10);

/////////////////////////////////////////////////////////////////////////////////////////// KFNS#38265

UPDATE fac_setting
SET fac_setting_name = 'self_register_groep_keys'
WHERE fac_setting_name = 'self_register_groep_key';

/////////////////////////////////////////////////////////////////////////////////////////// UWVA#38459
CREATE VIEW bez_v_udr_reserveringbezoeker AS SELECT '' dummy FROM DUAL;

INSERT INTO fac_usrrap (fac_usrrap_omschrijving, fac_usrrap_view_name,fac_usrrap_info, fac_functie_key, fac_usrrap_functie)
 SELECT 'UDR: Bezoekers bij reserveringen','BEZ_V_UDR_RESERVERINGBEZOEKER','Basisrapport voor bezoekers met reserveringsgegevens', fac_functie_key, 32
   FROM fac_functie WHERE fac_functie_code='WEB_UDRMAN'
    AND NOT EXISTS (SELECT '' FROM fac_usrrap WHERE UPPER(fac_usrrap_view_name)='BEZ_V_UDR_RESERVERINGBEZOEKER');

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39312
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'alg_kenmerk_niveau', 'level')
 WHERE fac_menuitems_url LIKE '%alg_kenmerk.asp%';
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'prs_kenmerk_niveau', 'level')
 WHERE fac_menuitems_url LIKE '%prs_kenmerk.asp%';
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'ALG_KENMERK_NIVEAU', 'level')
 WHERE fac_menuitems_url LIKE '%alg_kenmerk.asp%';
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'PRS_KENMERK_NIVEAU', 'level')
 WHERE fac_menuitems_url LIKE '%prs_kenmerk.asp%';

/////////////////////////////////////////////////////////////////////////////////////////// HSLE#36221
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'fac_usergraph', 'fac_usrgraph')
 WHERE fac_menuitems_url LIKE '%fac_usergraph%';
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'fac_notificatiejob', 'fac_notificatie_job')
 WHERE fac_menuitems_url LIKE '%fac_notificatiejob%';
UPDATE fac_menuitems
   SET fac_menuitems_url = REPLACE(fac_menuitems_url, 'mld_stdmelding_groep', 'mld_stdmeldinggroep')
 WHERE fac_menuitems_url LIKE '%mld_stdmelding_groep%';

/////////////////////////////////////////////////////////////////////////////////////////// ASTE#37915
ALTER TABLE prs_perslid ADD prs_perslid_timezone
    VARCHAR2(40);

/////////////////////////////////////////////////////////////////////////////////////////// MARX#39774
ALTER TABLE fin_factuurregel MODIFY (fin_factuurregel_omschrijving VARCHAR2(250));
ALTER TABLE fac_imp_factuur MODIFY (omschrijving VARCHAR2(250));

/////////////////////////////////////////////////////////////////////////////////////////// DJIN#36213

CREATE TABLE aut_idp
(
    aut_idp_key
        NUMBER(10)
        CONSTRAINT aut_k_idp_key PRIMARY KEY,
    aut_idp_code            -- Voor &sso=<code>
        VARCHAR2(30),
    aut_idp_type            -- 1=Internal (login.asp, future use), 2=UID_DEC (deprecated),
        NUMBER(3),          -- 3=GUID-encrypted (deprecated), 4=JWT, 5=SAML (future use)
    aut_idp_algorithm       -- HS256 is HMAC-SHA256
        VARCHAR2(30),
    aut_idp_omschrijving
        VARCHAR2(30),
    aut_idp_opmerking
        VARCHAR2(320),
    aut_idp_secret
        VARCHAR2(128),
    aut_idp_audience
        VARCHAR2(128),
    aut_idp_issuer
        VARCHAR2(128),
    aut_idp_remote_loginurl
        VARCHAR2(128),
    aut_idp_remote_logouturl
        VARCHAR2(128),
    aut_idp_saml_metaurl
        VARCHAR2(128),
    aut_idp_clockskew
        NUMBER(10),
    aut_idp_duration
        NUMBER(10),
    aut_idp_autocreate
        NUMBER(1)
        DEFAULT 0 -- +1: create; +2: update
        NOT NULL,
-- Note: these column are defined in PRS_TAB.SRC
--    prs_afdeling_key         NUMBER(10)
--    prs_bedrijf_key          NUMBER(10)
    fac_functie_key
        NUMBER(10)
        CONSTRAINT aut_r_idp_functie REFERENCES fac_functie(fac_functie_key),
    aut_idp_internal        -- can be used for FACFAC
        NUMBER(1)
        DEFAULT 0 NOT NULL,
    aut_idp_ipfilter
        VARCHAR2(320),
    aut_idp_ipauto
        NUMBER(1)
        DEFAULT 0 NOT NULL,
    aut_idp_loglevel
      NUMBER(1) DEFAULT 0 NOT NULL,
    aut_idp_aanmaak
        DATE
        DEFAULT SYSDATE
);

CREATE TABLE aut_idp_map
(
    aut_idp_map_key
        NUMBER(10)
        CONSTRAINT aut_k_idp_map_key PRIMARY KEY,
    aut_idp_key
        NUMBER(10)
        CONSTRAINT aut_r_idp_map_id REFERENCES aut_idp(aut_idp_key) ON DELETE CASCADE,
    aut_idp_map_from --  as sent in JWT
        VARCHAR(100)
        NOT NULL,
    aut_idp_map_to -- FACILITOR column of 1000+kenmerk_key
        NUMBER(10)
        NOT NULL,
    aut_idp_map_identify
        NUMBER(1)
        DEFAULT 0
        NOT NULL,
    aut_idp_map_default
        VARCHAR(256),
    aut_idp_map_aanmaak
        DATE
        DEFAULT SYSDATE
);
ALTER TABLE aut_idp
ADD
(
    prs_bedrijf_key
        NUMBER(10)
        CONSTRAINT aut_r_idp_prs_bedrijf REFERENCES prs_bedrijf(prs_bedrijf_key) ON DELETE CASCADE
);
ALTER TABLE aut_idp ADD
(
    prs_afdeling_key
       NUMBER(10)
       CONSTRAINT aut_r_idp_prs_afdeling REFERENCES prs_afdeling(prs_afdeling_key) ON DELETE CASCADE
);

CREATE SEQUENCE aut_s_aut_idp_key               MINVALUE 1;
CREATE SEQUENCE aut_s_aut_idp_map_key           MINVALUE 1;

CREATE UNIQUE INDEX aut_i_idp_code ON aut_idp(aut_idp_code);
CREATE UNIQUE INDEX aut_i_idp2 ON aut_idp(aut_idp_issuer, aut_idp_audience, aut_idp_type);

-- Alleen nodig voor het conversiestatement
CREATE OR REPLACE TRIGGER aut_t_aut_idp_B_IU
BEFORE INSERT OR UPDATE ON aut_idp
FOR EACH ROW
BEGIN
   UPDATE_PRIMARY_KEY(aut_idp_key, aut_s_aut_idp_key);
   :new.aut_idp_code := UPPER(:new.aut_idp_code);
END;
/

INSERT INTO aut_idp (
    aut_idp_code,
    aut_idp_type,
    aut_idp_algorithm,
    aut_idp_omschrijving,
    aut_idp_opmerking,
    aut_idp_secret,
    aut_idp_audience,
    aut_idp_issuer,
    aut_idp_remote_loginurl,
    aut_idp_remote_logouturl,
    aut_idp_clockskew,
    aut_idp_duration,
    aut_idp_internal,
    aut_idp_ipfilter,
    aut_idp_aanmaak)
SELECT
    fac_idp_code,
    fac_idp_type,
    fac_idp_algorithm,
    fac_idp_omschrijving,
    fac_idp_opmerking,
    fac_idp_secret,
    fac_idp_audience,
    COALESCE (fac_idp_issuer, 'KEY_' || fac_idp_key),
    fac_idp_remote_loginurl,
    fac_idp_remote_logouturl,
    fac_idp_clockskew,
    fac_idp_duration,
    fac_idp_internal,
    fac_idp_ipfilter,
    fac_idp_aanmaak
FROM fac_idp;


UPDATE fac_menu
   SET fac_menu_alturl = 'appl/mgt/aut_idp.asp', fac_menu_altlabel = 'lcl_menu_aut_idp'
 WHERE fac_menu_alturl = 'appl/mgt/fac_idp.asp';

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39750
-- Clients (zoals al dan niet native App's)
CREATE TABLE aut_client
(
    aut_client_key
        NUMBER(10)
        CONSTRAINT aut_k_aut_client_key PRIMARY KEY,
    aut_client_id
        VARCHAR2(64),
    aut_client_type            -- 1=Internal (login.asp, future use), 2=UID_DEC (deprecated),
        NUMBER(3),             -- 3=GUID-encrypted (deprecated), 4=JWT, 5=SAML (future use)
    aut_client_omschrijving
        VARCHAR2(30),
    aut_client_opmerking
        VARCHAR2(320),
    aut_client_secret
        VARCHAR2(128),
    aut_client_customuri -- future use
        VARCHAR2(128),
    aut_client_aanmaak
        DATE
        DEFAULT SYSDATE
);

-- Koppeling client en (toestemming gegeven door) perslid
CREATE TABLE aut_client_perslid
(
    aut_client_perslid_key
        NUMBER(10)
        CONSTRAINT aut_k_client_perslid PRIMARY KEY,
    aut_client_key
        NUMBER(10)
        CONSTRAINT aut_r_aut_client_id REFERENCES aut_client(aut_client_key) ON DELETE CASCADE,
    aut_client_perslid_device_id
        VARCHAR(320),
    aut_client_perslid_scope
        VARCHAR(320)
        DEFAULT NULL,
    aut_client_perslid_pushtoken
        VARCHAR(320),
    aut_client_perslid_refreshtkn -- unused yet
        VARCHAR(320),
    aut_client_perslid_refreshdate
        DATE,
    aut_client_perslid_accesstoken
        VARCHAR(320),
    aut_client_perslid_accessdate
        DATE,
    aut_client_perslid_login -- wanneer voor het laatst de app gebruikt
        DATE,
// Note: this column is defined in PRS_TAB.SRC
//    prs_perslid_key
//        NUMBER(10)
//        CONSTRAINT aut_r_aut_client_perslid REFERENCES prs_perslid(prs_perslid_key) ON DELETE CASCADE
//        CONSTRAINT aut_c_aut_client_perslid CHECK(prs_perslid_key IS NOT NULL),
    aut_client_perslid_aanmaak
        DATE
        DEFAULT SYSDATE
);

ALTER TABLE aut_client_perslid ADD (
    prs_perslid_key
        NUMBER(10)
        CONSTRAINT aut_r_aut_client_perslid REFERENCES prs_perslid(prs_perslid_key) ON DELETE CASCADE
        CONSTRAINT aut_c_aut_client_perslid CHECK(prs_perslid_key IS NOT NULL)
);

CREATE SEQUENCE aut_s_aut_client_key         MINVALUE 1;
CREATE SEQUENCE aut_s_aut_client_perslid_key MINVALUE 1;

DEF_MENUENTRY(2, 99110, 'lcl_menu_aut_client'          , '', 'FAC', 'appl/mgt/aut_client.asp', 0, 0, 'WEB_FACTAB');

/////////////////////////////////////////////////////////////////////////////////////////// FSN#36229
ALTER TABLE fac_functie
ADD fac_functie_volgnr NUMBER(10);

// As previous DB version
UPDATE fac_functie
   SET fac_functie_volgnr =
          CASE
             WHEN SUBSTR (fac_functie_code, 8, 3) IN ('USE', 'FOF', 'BOF')
                  AND SUBSTR (fac_functie_code, 5, 3) <> 'UUR'
             THEN 250
             WHEN SUBSTR (fac_functie_code, 8, 3) IN ('BAC', 'MAN')
             THEN 500
             WHEN SUBSTR (fac_functie_code, 8, 3) IN ('BO2', 'BO3', 'AFR', 'NOS', 'OAP')
             THEN 750
          END;

// In use
UPDATE fac_functie ff
   SET fac_functie_volgnr = 1000
 WHERE EXISTS (SELECT 'x'
                 FROM fac_groeprechten fgr, fac_groep fg, fac_functie ff2
                WHERE EXISTS (SELECT 'y'
                                FROM fac_gebruikersgroep fgg
                               WHERE fgg.fac_groep_key = fg.fac_groep_key)
                  AND fg.fac_groep_upper NOT IN ('_ADMIN', '_FACILITOR')
                  AND ff.fac_functie_key = ff2.fac_functie_key
                  AND ff2.fac_functie_key = fgr.fac_functie_key
                  AND fgr.fac_groep_key = fg.fac_groep_key
                  AND ff2.fac_functie_volgnr IS NULL);

DROP TRIGGER fac_t_fac_functie_B_IU;

/////////////////////////////////////////////////////////////////////////////////////////// MARX#39537
ALTER TABLE mld_srtkenmerk DROP CONSTRAINT mld_c_mld_srtkenmerk_systeem;
ALTER TABLE mld_srtkenmerk
     MODIFY mld_srtkenmerk_systeem DEFAULT 0;
UPDATE mld_srtkenmerk
   SET mld_srtkenmerk_systeem = 0
 WHERE mld_srtkenmerk_systeem IS NULL;
ALTER TABLE mld_srtkenmerk
    ADD CONSTRAINT mld_c_mld_srtkenmerk_systeem
       CHECK(mld_srtkenmerk_systeem IS NOT NULL);


/////////////////////////////////////////////////////////////////////////////////////////// ARAI#38183
DEF_FAC_SRTNOT('ORDHLT', 0, 'lcl_noti_ORDHLT', 'mld/mld_opdr.asp?opdr_key=', '0', 'opdracht', 10);
DEF_FAC_SRTNOT('ORDRSM', 0, 'lcl_noti_ORDRSM', 'mld/mld_opdr.asp?opdr_key=', '0', 'opdracht', 10);

ALTER TRIGGER mld_t_mld_opdr_B_IU DISABLE;
ALTER TABLE mld_opdr
  ADD mld_opdr_halted  -- is de opdracht onderbroken {0=nee (default) | 1=ja}
    NUMBER(1)
    DEFAULT (0)
    NOT NULL
    CONSTRAINT mld_c_mld_opdr_halted CHECK(mld_opdr_halted IN (0, 1));
ALTER TRIGGER mld_t_mld_opdr_B_IU ENABLE;

/////////////////////////////////////////////////////////////////////////////////////////// ARAI#38184
ALTER TABLE mld_typeopdr
  ADD mld_typeopdr_sequential NUMBER(1) DEFAULT 0 NOT NULL;

/////////////////////////////////////////////////////////////////////////////////////////// FSN#40101
ALTER TABLE ins_deel MODIFY (ins_deel_aantal NUMBER(8,2));
/////////////////////////////////////////////////////////////////////////////////////////// FSN#40190
ALTER TABLE ins_srtcontroledl_xcp ADD ins_srtcontroledl_xcp_aantal NUMBER(8,2);
ALTER TABLE ins_srtcontroledl_xcp ADD ins_srtcontroledl_xcp_aanteh VARCHAR2(30);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#40186
ALTER TABLE mld_stdmsrtruimte ADD mld_stdmsrtruimte_regime NUMBER(2)
 CONSTRAINT mld_c_stdmsrtruimte_regime CHECK (mld_stdmsrtruimte_regime IN (1,2,3));

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39832
ALTER TABLE mld_melding DROP CONSTRAINT mld_r_mld_workflowstep_key4;
ALTER TABLE mld_melding MODIFY mld_workflowstep_key CONSTRAINT mld_r_mld_workflowstep_key4 REFERENCES mld_workflowstep(mld_workflowstep_key);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#37488
ALTER TABLE res_disc_params ADD prs_bedrijf_key NUMBER(10) CONSTRAINT res_r_prs_bedrijf_key REFERENCES prs_bedrijf (prs_bedrijf_key);

/////////////////////////////////////////////////////////////////////////////////////////// STAM#39620
ALTER TABLE mld_stdmelding ADD mld_stdmelding_externurl VARCHAR2(1024);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#37274
CREATE VIEW ins_v_udr_deelinspect AS SELECT '' dummy FROM DUAL;

INSERT INTO fac_usrrap (fac_usrrap_omschrijving, fac_usrrap_view_name,fac_usrrap_info, fac_functie_key, fac_usrrap_functie)
 SELECT 'UDR: Object inspecties','INS_V_UDR_DEELINSPECT','Basisrapport voor object inspectie rapportages', fac_functie_key, 32
   FROM fac_functie WHERE fac_functie_code='WEB_UDRMAN'
    AND NOT EXISTS (SELECT '' FROM fac_usrrap WHERE UPPER(fac_usrrap_view_name)='INS_V_UDR_DEELINSPECT');

CREATE VIEW ins_v_udr_deelsrtcontrole AS SELECT '' dummy FROM DUAL;

INSERT INTO fac_usrrap (fac_usrrap_omschrijving, fac_usrrap_view_name,fac_usrrap_info, fac_functie_key, fac_usrrap_functie)
 SELECT 'UDR: Object soort controles','INS_V_UDR_DEELSRTCONTROLE','Basisrapport voor object soort controle rapportages', fac_functie_key, 32
   FROM fac_functie WHERE fac_functie_code='WEB_UDRMAN'
    AND NOT EXISTS (SELECT '' FROM fac_usrrap WHERE UPPER(fac_usrrap_view_name)='INS_V_UDR_DEELSRTCONTROLE');

/////////////////////////////////////////////////////////////////////////////////////////// KFNS#38663
CREATE SEQUENCE alg_s_alg_algfaq_key MINVALUE 1;

CREATE_TABLE(alg_algfaq, 0)
(
    alg_algfaq_key
        NUMBER(10)
        CONSTRAINT alg_k_algfaq_key PRIMARY KEY,
    alg_locatie_key
        NUMBER(10)
        NOT_NULL(alg_locatie_key, mld_c_alg_locatie_key)
        CONSTRAINT mld_r_mld_locatie_key1 REFERENCES alg_locatie(alg_locatie_key) ON DELETE CASCADE,
    alg_onroerendgoed_keys
        NUMBER(10),
    fac_faq_key
        NUMBER(10)
        NOT_NULL(fac_faq_key, alg_c_fac_faq_key)
        CONSTRAINT alg_r_fac_faq_key1 REFERENCES fac_faq(fac_faq_key) ON DELETE CASCADE
);

/////////////////////////////////////////////////////////////////////////////////////////// KFNS#37931
DEF_FAC_SRTNOT('ORDDAT', 0, 'lcl_noti_ORDDAT', 'mld/mld_opdr.asp?opdr_key=', '0', 'opdracht', 60);

/////////////////////////////////////////////////////////////////////////////////////////// AAIT#39909
ALTER TABLE prs_bedrijfadres
    ADD prs_bedrijfadres_lockuser_key
        NUMBER(10)
        CONSTRAINT prs_r_prs_bedrijfadres_lckser REFERENCES prs_perslid(prs_perslid_key);

ALTER TABLE prs_bedrijfadres
    ADD prs_bedrijfadres_locksecret
        VARCHAR2(128);

ALTER TABLE prs_bedrijfadres
    ADD prs_bedrijfadres_lockexpire
        NUMBER(10);

/////////////////////////////////////////////////////////////////////////////////////////// FSN#40442
DEF_MENUENTRY(2, 99130, 'lcl_menu_fac_anysql'          , '', 'FAC', 'appl/mgt/mgt_genericsql.asp', 0, 0, 'WEB_FACFAC');

///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////////// GENERAL

/////////////////////////////////////////////////////////////////////////////////////////// CLEANUP

/////////////////////////////////////////////////////////////////////////////////////////// FSN#39586
DELETE fac_localeitems
 WHERE fac_localeitems_dialect_id = 'MLD_SRTDISCIPLINE_KEY'
   AND fac_localeitems_lcl IN ('lcl_mld_urg_hold1',
                               'lcl_mld_urg_hoog1',
                               'lcl_mld_urg_kritiek1',
                               'lcl_mld_urg_laag1',
                               'lcl_mld_urg_normaal1');

/////////////////////////////////////////////////////////////////////////////////////////// FSN#31475
UPDATE cnt_disc_params SET cnt_srtcontract_type=4 WHERE cnt_srtcontract_type=2;
DELETE FROM cnt_typecontract WHERE cnt_typecontract_key=2;

DROP VIEW cnt_v_aanwezigcontract_data;
DROP VIEW cnt_v_allonroerendgoed;
DROP VIEW cnt_v_contract_locatie_geg;
DROP VIEW cnt_v_cnt_contract_onrgoed_new;
DROP VIEW cnt_v_cnt_contract_onrgoed_cur;
DROP VIEW cnt_v_cnt_contract_onrgoed_mut;
DROP VIEW cnt_v_contract_huurder;

DROP INDEX cnt_i_cnt_contract_onrg1;
DROP INDEX cnt_i_cnt_contract_onrg2;
DROP TABLE cnt_contract_onrgoed PURGE;
DROP TABLE cnt_mutatie_status PURGE;
DROP TABLE cnt_mutatie PURGE;

DROP SEQUENCE cnt_s_cnt_mutatie_key;
DROP SEQUENCE cnt_s_cnt_onrgoed_key;

/////////////////////////////////////////////////////////////////////////////////////////// FSN#38888

DROP VIEW mld_v_stdmelding_kenmerk;
DROP VIEW alg_v_alg_ruimte_verdieping;
DROP VIEW all_backoffice;
DROP VIEW all_v_aanwezigbackoffice;
DROP VIEW all_v_aanwezigafdeling;
DROP VIEW all_v_aanwezigbedrijf;
DROP VIEW cad_v_cad_tekening_gegevens;
DROP VIEW cad_v_cad_tekening;
DROP VIEW cad_v_ins_deel;
DROP VIEW cad_v_lpn_ins_deel_1;
DROP VIEW cad_v_lpn_ins_deel_2;
DROP VIEW cad_v_lpn_prs_werkplek_1;
DROP VIEW cad_v_contour;
DROP VIEW cad_v_discipline;
DROP VIEW cad_v_plattegrond;
DROP VIEW cad_v_prs_werkplek;
DROP VIEW ins_v_deel_acadsymbol;
DROP VIEW ins_v_compositie_gegevens;
DROP VIEW fac_v_webfunctie;
DROP VIEW fac_v_webuser;
DROP VIEW fac_v_webfunctie_discipline;
DROP VIEW fac_v_functie_discipline;
DROP VIEW fac_v_gebruikersgroepgegevens;
DROP VIEW all_v_srtdeel_gegevens;
DROP VIEW all_v_srtgroep_gegevens;
DROP VIEW all_v_aanwezigsrtdeel;
DROP VIEW all_v_aanwezigsrtgroep;
DROP VIEW all_v_aanwezigdiscipline;
DROP VIEW all_discipline;
DROP VIEW all_v_aanwezigdeel;

DROP VIEW fac_v_perfmon_sample_overall60;
DROP VIEW fac_v_perfmon_sample_overall10;
DROP VIEW fac_v_perfmon_sample60;
DROP VIEW fac_v_perfmon_sample10;
DROP VIEW fac_v_perfmon_sample_ip;
DROP VIEW fac_v_perfmon_sample_user;

DROP TABLE fac_error PURGE;
DROP TABLE fac_errorlog PURGE;

///////////////////////////////////////////////////////////////////////////////////////////
REGISTERONCE('$Id$')

#include "epilogue.inc"
