Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions datamodel/brk/brk2.0_oracle_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ CREATE OR REPLACE VIEW vb_util_zk_recht
ar_teller,
ar_noemer,
subject_identif,
isgebaseerdop,
isgebaseerdop2,
mandeligheid_identif,
koz_identif,
indic_betrokken_in_splitsing,
Expand All @@ -512,11 +514,20 @@ SELECT zakrecht.identificatie AS zr_i
-- BRMO-340: samenvoegen van de tennamevan (tenaamstelling) op de zakelijke rechten die bestemd zijn tot een mandeligheid
COALESCE(tenaamstelling.tennamevan, '') || COALESCE(vve.heeftverenigingvaneigenaren, '') ||
COALESCE(tenaamstelling2.tennamevan, '') AS subject_identif,
-- BRMO-401: Bijvoegen van de isgebaseerdop
CASE
WHEN tenaamstelling.isgebaseerdop IS NULL THEN mandeligheid.isgebaseerdop
ELSE tenaamstelling.isgebaseerdop
END AS isgebaseerdop,
CASE
WHEN tenaamstelling.isgebaseerdop2 IS NULL THEN mandeligheid.isgebaseerdop2
ELSE tenaamstelling.isgebaseerdop2
END AS isgebaseerdop2,
-- BRMO-340: toevoegen van mandeligheidsidentificatie, zodat het duidelijk is dat het een mandelige zaak betreft.
mandeligheid.identificatie AS mandeligheid_identif,
vuzrok.rustop_zak_recht AS koz_identif,
CASE WHEN (zakrecht.isbetrokkenbij is not NULL) THEN 1 ELSE 0 END AS indic_betrokken_in_splitsing,
zakrecht.aard AS omschr_aard_verkregen_recht,
zakrecht.aard AS omschr_aard_verkregenr_recht,
zakrecht.aard AS fk_3avr_aand,
(SELECT LISTAGG(
'id: ' || COALESCE(aantekening.identificatie, '') || ', '
Expand Down Expand Up @@ -552,6 +563,8 @@ COMMENT ON TABLE vb_util_zk_recht IS
* ar_teller: teller van aandeel,
* ar_noemer: noemer van aandeel,
* subject_identif: natuurlijk id van subject (natuurlijk of niet natuurlijk) welke rechthebbende is,
* isgebaseerdop: -
* isgebaseerdop2: -
* mandeligheid_identif: identificatie van een mandeligheid, een gemeenschappelijk eigendom van een onroerende zaak,
* koz_identif: natuurlijk id van kadastrale onroerende zaak (perceel of appratementsrecht) dat gekoppeld is,
* indic_betrokken_in_splitsing: -,
Expand All @@ -565,6 +578,10 @@ CREATE MATERIALIZED VIEW mb_zr_rechth
zr_identif,
ingangsdatum_recht,
subject_identif,
isgebaseerdop,
tijdstipaanbieding,
isgebaseerdop2,
tijdstipaanbieding2,
mandeligheid_identif,
koz_identif,
aandeel,
Expand Down Expand Up @@ -596,6 +613,10 @@ SELECT CAST(ROWNUM AS INTEGER) AS objectid,
uzr.zr_identif as zr_identif,
uzr.ingangsdatum_recht,
uzr.subject_identif,
uzr.isgebaseerdop,
st1.tijdstipaanbieding,
uzr.isgebaseerdop2,
st2.tijdstipaanbieding AS tijdstipaanbieding2,
uzr.mandeligheid_identif,
uzr.koz_identif,
uzr.aandeel,
Expand Down Expand Up @@ -623,7 +644,23 @@ FROM vb_util_zk_recht uzr
JOIN
mb_subject vs
ON
uzr.subject_identif = vs.subject_identif;
uzr.subject_identif = vs.subject_identif
LEFT JOIN
stukdeel sd1
ON
sd1.identificatie = uzr.isgebaseerdop
LEFT JOIN
stukdeel sd2
ON
sd2.identificatie = uzr.isgebaseerdop2
LEFT JOIN
stuk st1
ON
sd1.deelvan = st1.identificatie
LEFT JOIN
stuk st2
ON
sd2.deelvan = st2.identificatie;

CREATE UNIQUE INDEX mb_zr_rechth_objectid ON mb_zr_rechth (objectid ASC);
CREATE INDEX mb_zr_rechth_identif ON mb_zr_rechth (zr_identif ASC);
Expand All @@ -636,6 +673,10 @@ COMMENT ON MATERIALIZED VIEW mb_zr_rechth IS
* zr_identif: natuurlijke id van zakelijk recht,
* ingangsdatum_recht: -
* subject_identif: natuurlijk id van subject (natuurlijk of niet natuurlijk) welke rechthebbende is,
* isgebaseerdop: -
* tijdstipaanbieding: -
* isgebaseerdop2: -
* tijdstipaanbieding2: -
* mandeligheid_identif: identificatie van een mandeligheid, een gemeenschappelijk eigendom van een onroerende zaak,
* koz_identif: natuurlijk id van kadastrale onroerende zaak (perceel of appratementsrecht) dat gekoppeld is,
* aandeel: samenvoeging van teller en noemer (1/2),
Expand Down
47 changes: 46 additions & 1 deletion datamodel/brk/brk2.0_postgresql_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ CREATE OR REPLACE VIEW
ar_teller,
ar_noemer,
subject_identif,
isgebaseerdop,
isgebaseerdop2,
mandeligheid_identif,
koz_identif,
indic_betrokken_in_splitsing,
Expand All @@ -539,9 +541,18 @@ SELECT zakrecht.identificatie AS zr_identif,
COALESCE(tenaamstelling.tennamevan, '') || COALESCE(vve.heeftverenigingvaneigenaren, '') ||
COALESCE(tenaamstelling2.tennamevan, '')
AS subject_identif,
-- BRMO-401: Bijvoegen van de isgebaseerdop
CASE
WHEN tenaamstelling.isgebaseerdop IS NULL THEN mandeligheid.isgebaseerdop
ELSE tenaamstelling.isgebaseerdop
END AS isgebaseerdop,
CASE
WHEN tenaamstelling.isgebaseerdop2 IS NULL THEN mandeligheid.isgebaseerdop2
ELSE tenaamstelling.isgebaseerdop2
END AS isgebaseerdop2,
-- BRMO-340: toevoegen van mandeligheidsidentificatie, zodat het duidelijk is dat het een mandelige zaak betreft.
mandeligheid.identificatie AS mandeligheid_identif,
vuzrok.rustop_zak_recht AS koz_identif,
vuzrok.rustop_zak_recht AS koz_identif,
(zakrecht.isbetrokkenbij is not NULL)::bool AS indic_betrokken_in_splitsing,
zakrecht.aard AS omschr_aard_verkregen_recht,
zakrecht.aard AS fk_3avr_aand,
Expand Down Expand Up @@ -578,6 +589,8 @@ COMMENT ON VIEW vb_util_zk_recht IS
* ar_teller: teller van aandeel,
* ar_noemer: noemer van aandeel,
* subject_identif: natuurlijk id van subject (natuurlijk of niet natuurlijk) welke rechthebbende is,
* isgebaseerdop: -
* isgebaseerdop2: -
* mandeligheid_identif: identificatie van een mandeligheid, een gemeenschappelijk eigendom van een onroerende zaak,
* koz_identif: natuurlijk id van kadastrale onroerende zaak (perceel of appratementsrecht) dat gekoppeld is,
* indic_betrokken_in_splitsing: -,
Expand All @@ -591,6 +604,10 @@ CREATE MATERIALIZED VIEW mb_zr_rechth
zr_identif,
ingangsdatum_recht,
subject_identif,
isgebaseerdop,
tijdstipaanbieding,
isgebaseerdop2,
tijdstipaanbieding2,
mandeligheid_identif,
koz_identif,
aandeel,
Expand Down Expand Up @@ -620,6 +637,10 @@ SELECT row_number() OVER () AS objectid,
uzr.zr_identif,
uzr.ingangsdatum_recht,
uzr.subject_identif,
uzr.isgebaseerdop,
st1.tijdstipaanbieding,
uzr.isgebaseerdop2,
st2.tijdstipaanbieding AS tijdstipaanbieding2,
uzr.mandeligheid_identif,
uzr.koz_identif,
uzr.aandeel,
Expand All @@ -645,6 +666,10 @@ SELECT row_number() OVER () AS objectid,
persoon.kvk_nummer
FROM vb_util_zk_recht uzr
JOIN mb_subject persoon ON uzr.subject_identif = persoon.subject_identif
LEFT JOIN brk.stukdeel sd1 ON sd1.identificatie::text = uzr.isgebaseerdop
LEFT JOIN brk.stukdeel sd2 ON sd2.identificatie::text = uzr.isgebaseerdop2
LEFT JOIN brk.stuk st1 ON sd1.deelvan::text = st1.identificatie::text
LEFT JOIN brk.stuk st2 ON sd2.deelvan::text = st2.identificatie::text
WITH NO DATA;

CREATE UNIQUE INDEX mb_zr_rechth_objectid ON mb_zr_rechth USING btree (objectid);
Expand All @@ -658,6 +683,10 @@ COMMENT ON MATERIALIZED VIEW mb_zr_rechth IS
* zr_identif: natuurlijke id van zakelijk recht,
* ingangsdatum_recht: -
* subject_identif: natuurlijk id van subject (natuurlijk of niet natuurlijk) welke rechthebbende is,
* isgebaseerdop: -
* tijdstipaanbieding: -
* isgebaseerdop2: -
* tijdstipaanbieding2: -
* mandeligheid_identif: identificatie van een mandeligheid, een gemeenschappelijk eigendom van een onroerende zaak,
* koz_identif: natuurlijk id van kadastrale onroerende zaak (perceel of appratementsrecht) dat gekoppeld is,
* aandeel: samenvoeging van teller en noemer (1/2),
Expand Down Expand Up @@ -689,6 +718,10 @@ CREATE MATERIALIZED VIEW mb_avg_zr_rechth
zr_identif,
ingangsdatum_recht,
subject_identif,
isgebaseerdop,
tijdstipaanbieding,
isgebaseerdop2,
tijdstipaanbieding2,
mandeligheid_identif,
koz_identif,
aandeel,
Expand Down Expand Up @@ -718,6 +751,10 @@ SELECT row_number() OVER () AS objectid,
uzr.zr_identif as zr_identif,
uzr.ingangsdatum_recht,
uzr.subject_identif,
uzr.isgebaseerdop,
st1.tijdstipaanbieding,
uzr.isgebaseerdop2,
st2.tijdstipaanbieding AS tijdstipaanbieding2,
uzr.mandeligheid_identif,
uzr.koz_identif,
uzr.aandeel,
Expand All @@ -743,6 +780,10 @@ SELECT row_number() OVER () AS objectid,
avgpersoon.kvk_nummer
FROM vb_util_zk_recht uzr
JOIN mb_avg_subject avgpersoon ON uzr.subject_identif = avgpersoon.subject_identif
LEFT JOIN brk.stukdeel sd1 ON sd1.identificatie::text = uzr.isgebaseerdop::text
LEFT JOIN brk.stukdeel sd2 ON sd2.identificatie::text = uzr.isgebaseerdop2::text
LEFT JOIN brk.stuk st1 ON sd1.deelvan::text = st1.identificatie::text
LEFT JOIN brk.stuk st2 ON sd2.deelvan::text = st2.identificatie::text
WITH NO DATA;

CREATE UNIQUE INDEX mb_avg_zr_rechth_objectid ON mb_avg_zr_rechth USING btree (objectid);
Expand All @@ -756,6 +797,10 @@ COMMENT ON MATERIALIZED VIEW mb_avg_zr_rechth IS
* zr_identif: natuurlijke id van zakelijk recht,
* ingangsdatum_recht: -,
* subject_identif: natuurlijk id van subject (natuurlijk of niet natuurlijk) welke rechthebbende is,
* isgebaseerdop: -
* tijdstipaanbieding: -
* isgebaseerdop2: -
* tijdstipaanbieding2: -
* mandeligheid_identif: identificatie van een mandeligheid, een gemeenschappelijk eigendom van een onroerende zaak,
* koz_identif: natuurlijk id van kadastrale onroerende zaak (perceel of appratementsrecht) dat gekoppeld is,
* aandeel: samenvoeging van teller en noemer (1/2),
Expand Down
27 changes: 13 additions & 14 deletions datamodel/extra_scripts/oracle/210_bag2_brk2.0_mat_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ FROM (SELECT p.identificatie AS identificatie,
LEFT JOIN BRMO_BRK.objectlocatie o2 ON o2.heeft = o.identificatie
LEFT JOIN BRMO_BRK.adres a2 ON a2.identificatie = o2.betreft
LEFT JOIN mb_adresseerbaar_object_geometrie_bag maogb ON maogb.identificatie = a2.adresseerbaarobject;
-- [BRMO-401] GROUP BY, om dubbellingen te voorkomen. Deze ontstaan als een verblijfsobject in meerdere panden zit.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KJLammers de group by is niet geschikt voor oracle, het lukt mij niet om compleet geschikt te maken. het is een bijzondere group by met soortvan nested grouped waardes en aan het einde 'AS array_agg' wat ik erg apart vind.

AI beweert dat wat de group by probeert, niet mogelijk is met oracle. (de view zou dus ingrijpender gewijzigd moeten worden). maar dat geloof ik nietecht.

GROUP BY o.identificatie, o.begingeldigheid, a2.adresseerbaarobject, qry.type, ((COALESCE(o.sectie, '') || ' ') || COALESCE(o.perceelnummer, '')), ((((((COALESCE(o.akrkadastralegemeente, '') || ' ') || COALESCE(o.sectie, '')) || ' ') || COALESCE(o.perceelnummer, '')) || ' ') || COALESCE(o.appartementsrechtvolgnummer, '')), o.sectie, o.perceelnummer, o.appartementsrechtvolgnummer, o.akrkadastralegemeente, qry.soortgrootte, qry.kadastralegrootte, (st_area(qry.begrenzing_perceel)), NULL, o.aard_cultuur_onbebouwd, o.koopsom_bedrag, o.koopsom_koopjaar, o.koopsom_indicatiemeerobjecten, o.koopsom_valuta, (array_to_string(( SELECT array_agg(((((((((((((((((((('id: ' || r.identificatie) || ', ') || 'aard: ') || COALESCE(r.aard, '')) || ', ') || 'begin: ') || COALESCE(r.begingeldigheid, '')) || ', ') || 'beschrijving: ') || COALESCE(r.omschrijving, '')) || ', ') || 'eind: ') || COALESCE(r.einddatum, '')) || ', ') || 'koz-id: ') || COALESCE(r.aantekeningkadastraalobject, '')) || ', ') || 'subject-id: ') || COALESCE(r.betrokkenpersoon, '')) || '; ') AS array_agg
FROM brk.recht r
WHERE r.aantekeningkadastraalobject = o.identificatie), ' & ')), maogb.identificatienummeraanduiding, maogb.nummeraanduidingstatus, maogb.gemeente, maogb.woonplaats, maogb.straatnaam, maogb.huisnummer, maogb.huisletter, maogb.huisnummertoevoeging, maogb.postcode, maogb.gebruiksdoelen, maogb.oppervlakte, (st_x(st_transform(qry.plaatscoordinaten, 4326))), (st_y(st_transform(qry.plaatscoordinaten, 4326))), qry.begrenzing_perceel


COMMENT ON MATERIALIZED VIEW mb_kadastraleonroerendezakenmetadres IS
'commentaar view mb_kad_onrrnd_zk_adres:
Expand Down Expand Up @@ -209,15 +214,12 @@ SELECT CAST(ROWNUM AS INTEGER) AS objectid,
koz.lon,
koz.lat,
koz.begrenzing_perceel,
st1.tijdstipaanbieding as tijdstipaanbieding_stuk,
st2.tijdstipaanbieding as tijdstipaanbieding_stuk2
-- BRMO-401: tijdstipaanbieding nu uit mb_zr_rechth te halen.
zrr.tijdstipaanbieding AS tijdstipaanbieding_stuk,
zrr.tijdstipaanbieding2 AS tijdstipaanbieding_stuk2
FROM BRMO_BRK.mb_zr_rechth zrr
RIGHT JOIN mb_kadastraleonroerendezakenmetadres koz ON (zrr.koz_identif = koz.identificatie)
JOIN BRMO_BRK.recht r on zrr.zr_identif = r.van
LEFT JOIN BRMO_BRK.stukdeel sd1 ON sd1.identificatie = r.isgebaseerdop
LEFT JOIN BRMO_BRK.stukdeel sd2 ON sd2.identificatie = r.isgebaseerdop2
LEFT JOIN BRMO_BRK.stuk st1 ON sd1.deelvan = st1.identificatie
LEFT JOIN BRMO_BRK.stuk st2 ON sd2.deelvan = st2.identificatie;
GROUP BY koz.identificatie, koz.begingeldigheid_datum, koz.type, koz.aanduiding, koz.aanduiding2, koz.sectie, koz.perceelnummer, koz.appartementsrechtvolgnummer, koz.akrkadastralegemeente, koz.soortgrootte, koz.kadastralegrootte, koz.oppervlakte_geom, koz.deelperceelnummer, koz.omschr_deelperceel, koz.verkoop_datum, koz.aard_cultuur_onbebouwd, koz.koopsom_bedrag, koz.koopsom_koopjaar, koz.koopsom_indicatiemeerobjecten, koz.koopsom_valuta, koz.loc_omschr, zrr.zr_identif, zrr.ingangsdatum_recht, zrr.mandeligheid_identif, zrr.subject_identif, zrr.aandeel, zrr.omschr_aard_verkregenr_recht, zrr.indic_betrokken_in_splitsing, zrr.soort, zrr.geslachtsnaam, zrr.voorvoegsel, zrr.voornamen, zrr.aand_naamgebruik, zrr.geslachtsaand, zrr.naam, zrr.woonadres, zrr.geboortedatum, zrr.geboorteplaats, zrr.overlijdensdatum, zrr.bsn, zrr.organisatie_naam, zrr.rechtsvorm, zrr.statutaire_zetel, zrr.rsin, zrr.kvk_nummer, zrr.aantekeningen, koz.gemeente, koz.woonplaats, koz.straatnaam, koz.huisnummer, koz.huisletter, koz.huisnummertoevoeging, koz.postcode, koz.lon, koz.lat, koz.begrenzing_perceel, zrr.tijdstipaanbieding, zrr.tijdstipaanbieding2;

COMMENT ON MATERIALIZED VIEW mb_onroerendezakenmetrechthebbenden
IS 'commentaar view mb_onroerendezakenmetrechthebbenden:
Expand Down Expand Up @@ -356,15 +358,12 @@ SELECT CAST(ROWNUM AS INTEGER) AS objectid,
koz.lon,
koz.lat,
koz.begrenzing_perceel,
st1.tijdstipaanbieding as tijdstipaanbieding_stuk,
st2.tijdstipaanbieding as tijdstipaanbieding_stuk2
-- BRMO-401: tijdstipaanbieding nu uit mb_zr_rechth te halen.
zrr.tijdstipaanbieding AS tijdstipaanbieding_stuk,
zrr.tijdstipaanbieding2 AS tijdstipaanbieding_stuk2
FROM BRMO_BRK.mb_avg_zr_rechth zrr
RIGHT JOIN mb_kadastraleonroerendezakenmetadres koz ON (zrr.koz_identif = koz.identificatie)
JOIN BRMO_BRK.recht r on zrr.zr_identif = r.van
LEFT JOIN BRMO_BRK.stukdeel sd1 ON sd1.identificatie = r.isgebaseerdop
LEFT JOIN BRMO_BRK.stukdeel sd2 ON sd2.identificatie = r.isgebaseerdop2
LEFT JOIN BRMO_BRK.stuk st1 ON sd1.deelvan = st1.identificatie
LEFT JOIN BRMO_BRK.stuk st2 ON sd2.deelvan = st2.identificatie;
GROUP BY koz.identificatie, koz.begingeldigheid_datum, koz.type, koz.aanduiding, koz.aanduiding2, koz.sectie, koz.perceelnummer, koz.appartementsrechtvolgnummer, koz.akrkadastralegemeente, koz.soortgrootte, koz.kadastralegrootte, koz.oppervlakte_geom, koz.deelperceelnummer, koz.omschr_deelperceel, koz.verkoop_datum, koz.aard_cultuur_onbebouwd, koz.koopsom_bedrag, koz.koopsom_koopjaar, koz.koopsom_indicatiemeerobjecten, koz.koopsom_valuta, koz.loc_omschr, zrr.zr_identif, zrr.ingangsdatum_recht, zrr.mandeligheid_identif, zrr.subject_identif, zrr.aandeel, zrr.omschr_aard_verkregenr_recht, zrr.indic_betrokken_in_splitsing, zrr.soort, zrr.geslachtsnaam, zrr.voorvoegsel, zrr.voornamen, zrr.aand_naamgebruik, zrr.geslachtsaand, zrr.naam, zrr.woonadres, zrr.geboortedatum, zrr.geboorteplaats, zrr.overlijdensdatum, zrr.bsn, zrr.organisatie_naam, zrr.rechtsvorm, zrr.statutaire_zetel, zrr.rsin, zrr.kvk_nummer, zrr.aantekeningen, koz.gemeente, koz.woonplaats, koz.straatnaam, koz.huisnummer, koz.huisletter, koz.huisnummertoevoeging, koz.postcode, koz.lon, koz.lat, koz.begrenzing_perceel, zrr.tijdstipaanbieding, zrr.tijdstipaanbieding2;

COMMENT ON MATERIALIZED VIEW mb_avg_onroerendezakenmetrechthebbenden
IS 'commentaar view mb_avg_onroerendezakenmetrechthebbenden:
Expand Down
Loading