Index: /trunk/import/sichten_ORACLE.sql
===================================================================
--- /trunk/import/sichten_ORACLE.sql	(revision 251)
+++ /trunk/import/sichten_ORACLE.sql	(revision 252)
@@ -5,10 +5,10 @@
 CREATE OR REPLACE VIEW S_FLURSTUECK_NR
 AS 
- SELECT f.ogr_fid, 
-        p.ora_geometry,
-        f.zaehler::text || COALESCE ('/' || f.nenner::text, '') AS fsnum
+ SELECT f.OGR_FID, 
+        p.ORA_GEOMETRY,
+        f.zaehler || COALESCE ('/' || f.nenner, '') AS FSNUM
    FROM ap_pto             p
-   JOIN alkis_beziehungen  v  ON p.gml_id       = v.beziehung_von
-   JOIN ax_flurstueck      f  ON v.beziehung_zu = f.gml_id
+   JOIN alkis_beziehungen  v  ON p.GL_ID       = v.beziehung_von
+   JOIN ax_flurstueck      f  ON v.beziehung_zu = f.GL_ID
   WHERE v.beziehungsart = 'dientZurDarstellungVon' 
     AND p.endet IS NULL
@@ -18,19 +18,19 @@
 CREATE OR REPLACE VIEW S_FLURSTUECK_NR2
 AS 
-  SELECT f.ogr_fid, 
-         p.ora_geometry,
-         f.zaehler::text || COALESCE ('/' || f.nenner::text, '') AS fsnum
+  SELECT f.OGR_FID, 
+         p.ORA_GEOMETRY,
+         f.zaehler || COALESCE ('/' || f.nenner, '') AS FSNUM
     FROM ap_pto             p
-    JOIN alkis_beziehungen  v  ON p.gml_id       = v.beziehung_von
-    JOIN ax_flurstueck      f  ON v.beziehung_zu = f.gml_id
+    JOIN alkis_beziehungen  v  ON p.GL_ID       = v.beziehung_von
+    JOIN ax_flurstueck      f  ON v.beziehung_zu = f.GL_ID
    WHERE v.beziehungsart = 'dientZurDarstellungVon' 
      AND p.endet IS NULL
      AND f.endet IS NULL
  UNION 
-  SELECT f.ogr_fid,
-         ST_PointOnSurface(f.ora_geometry) AS wkb_geometry,
-         f.zaehler::text || COALESCE ('/' || f.nenner::text, '') AS fsnum
+  SELECT f.OGR_FID,
+         ST_PointOnSurface(f.ORA_GEOMETRY) AS wkb_geometry,
+         f.zaehler || COALESCE ('/' || f.nenner, '') AS FSNUM
     FROM      ax_flurstueck     f 
-    LEFT JOIN alkis_beziehungen v  ON v.beziehung_zu = f.gml_id
+    LEFT JOIN alkis_beziehungen v  ON v.beziehung_zu = f.GL_ID
    WHERE v.beziehungsart is NULL
      AND f.endet IS NULL
@@ -39,13 +39,13 @@
 CREATE OR REPLACE VIEW S_HAUSNUMMER_GEBAEUDE 
 AS 
- SELECT p.ogr_fid, 
-        p.ora_geometry,
-        p.drehwinkel * 57.296 AS drehwinkel,
+ SELECT p.OGR_FID, 
+        p.ORA_GEOMETRY,
+        p.DREHWINKEL * 57.296 AS DREHWINKEL,
         l.hausnummer
    FROM ap_pto p
    JOIN alkis_beziehungen v
-     ON p.gml_id = v.beziehung_von
+     ON p.GL_ID = v.beziehung_von
    JOIN AX_LAGEBEZEICHNUNGMITHAUSNUMME l
-     ON v.beziehung_zu  = l.gml_id
+     ON v.beziehung_zu  = l.GL_ID
   WHERE v.beziehungsart = 'dientZurDarstellungVon'
     AND p.endet IS NULL
@@ -54,13 +54,13 @@
 CREATE OR REPLACE VIEW S_NUMMER_NEBENGEBAEUDE 
 AS 
- SELECT p.ogr_fid, 
-        p.ora_geometry, 
-        p.drehwinkel * 57.296 AS drehwinkel,
+ SELECT p.OGR_FID, 
+        p.ORA_GEOMETRY, 
+        p.DREHWINKEL * 57.296 AS DREHWINKEL,
         l.laufendenummer
    FROM ap_pto p
    JOIN alkis_beziehungen v 
-     ON p.gml_id = v.beziehung_von
+     ON p.GL_ID = v.beziehung_von
    JOIN AX_LAGEBEZEICHNUNGMITPSEUDONUM l
-     ON v.beziehung_zu  = l.gml_id
+     ON v.beziehung_zu  = l.GL_ID
   WHERE v.beziehungsart = 'dientZurDarstellungVon'
     AND p.endet IS NULL
@@ -70,13 +70,13 @@
 CREATE OR REPLACE VIEW S_ZUGEHOERIGKEITSHAKEN_FLURSTU 
 AS 
- SELECT p.ogr_fid, 
-        p.ora_geometry, 
-        p.drehwinkel * 57.296 AS drehwinkel,
+ SELECT p.OGR_FID, 
+        p.ORA_GEOMETRY, 
+        p.DREHWINKEL * 57.296 AS DREHWINKEL,
         f.flurstueckskennzeichen
    FROM ap_ppo p
    JOIN alkis_beziehungen v
-     ON p.gml_id = v.beziehung_von
+     ON p.GL_ID = v.beziehung_von
    JOIN ax_flurstueck f
-     ON v.beziehung_zu = f.gml_id
+     ON v.beziehung_zu = f.GL_ID
   WHERE p.art = 'Haken'
     AND v.beziehungsart = 'dientZurDarstellungVon'
@@ -86,11 +86,11 @@
 CREATE OR REPLACE VIEW S_ZUORDUNGSPFEIL_FLURSTUECK 
 AS 
- SELECT l.ogr_fid, 
-        l.ora_geometry
+ SELECT l.OGR_FID, 
+        l.ORA_GEOMETRY
    FROM ap_lpo l
    JOIN alkis_beziehungen v
-     ON l.gml_id = v.beziehung_von
+     ON l.GL_ID = v.beziehung_von
    JOIN ax_flurstueck f
-     ON v.beziehung_zu = f.gml_id
+     ON v.beziehung_zu = f.GL_ID
   WHERE l.art = 'Pfeil'
     AND v.beziehungsart = 'dientZurDarstellungVon'
@@ -101,13 +101,13 @@
 CREATE OR REPLACE VIEW S_ZUORDUNGSPFEILSPITZE_FLURSTU 
 AS 
- SELECT l.ogr_fid, 
-        (((st_azimuth(st_pointn(l.ora_geometry, 1), 
-        st_pointn(l.ora_geometry, 2)) * (- (180)::double precision)) / pi()) + (90)::double precision) AS winkel, 
-        st_startpoint(l.ora_geometry) AS wkb_geometry 
+ SELECT l.OGR_FID, 
+        (((st_azimuth(st_pointn(l.ORA_GEOMETRY, 1), 
+        st_pointn(l.ORA_GEOMETRY, 2)) * (- (180)::double precision)) / pi()) + (90)::double precision) AS WINKEL, 
+        st_startpoint(l.ORA_GEOMETRY) AS wkb_geometry 
    FROM ap_lpo l
    JOIN alkis_beziehungen v
-     ON l.gml_id = v.beziehung_von
+     ON l.GL_ID = v.beziehung_von
    JOIN ax_flurstueck f
-     ON v.beziehung_zu = f.gml_id
+     ON v.beziehung_zu = f.GL_ID
   WHERE l.art = 'Pfeil'
     AND v.beziehungsart = 'dientZurDarstellungVon'
@@ -118,9 +118,9 @@
 CREATE OR REPLACE VIEW S_BESCHRIFTUNG 
 AS 
-  SELECT p.ogr_fid, 
+  SELECT p.OGR_FID, 
          p.schriftinhalt, 
          p.art, 
-         p.drehwinkel * 57.296 AS winkel,
-         p.ora_geometry 
+         p.DREHWINKEL * 57.296 AS WINKEL,
+         p.ORA_GEOMETRY 
     FROM ap_pto p
    WHERE not p.schriftinhalt IS NULL 
@@ -130,11 +130,11 @@
 CREATE OR REPLACE VIEW S_ZUORDUNGSPFEIL_GEBAEUDE 
 AS 
- SELECT l.ogr_fid, 
-        l.ora_geometry
+ SELECT l.OGR_FID, 
+        l.ORA_GEOMETRY
    FROM ap_lpo l
    JOIN alkis_beziehungen v
-     ON l.gml_id = v.beziehung_von
+     ON l.GL_ID = v.beziehung_von
    JOIN ax_gebaeude g
-     ON v.beziehung_zu = g.gml_id
+     ON v.beziehung_zu = g.GL_ID
   WHERE l.art = 'Pfeil'
     AND v.beziehungsart = 'dientZurDarstellungVon'
@@ -144,55 +144,55 @@
 CREATE OR REPLACE VIEW SK2004_ZUORDNUNGSPFEIL 
 AS
- SELECT ap.ogr_fid, ap.ora_geometry 
+ SELECT ap.OGR_FID, ap.ORA_GEOMETRY 
  FROM ap_lpo ap 
  WHERE ((ap.signaturnummer = '2004') 
-   AND ('DKKM1000'::text ~~ ANY ((ap.advstandardmodell)::text[])));
+   AND ('DKKM1000' ~~ ANY ((ap.advstandardmodell)[])));
 COMMENT ON VIEW SK2004_ZUORDNUNGSPFEIL IS 'fuer Kartendarstellung: Zuordnungspfeil FlurstÃŒcksnummer"';
 CREATE OR REPLACE VIEW SK2004_ZUORDNUNGSPFEIL_SPITZE 
 AS
- SELECT ap.ogr_fid, (((st_azimuth(st_pointn(ap.ora_geometry, 1), 
-        st_pointn(ap.ora_geometry, 2)) * (- (180)::double precision)) / pi()) + (90)::double precision) AS winkel, 
-        st_startpoint(ap.ora_geometry) AS wkb_geometry 
+ SELECT ap.OGR_FID, (((st_azimuth(st_pointn(ap.ORA_GEOMETRY, 1), 
+        st_pointn(ap.ORA_GEOMETRY, 2)) * (- (180)::double precision)) / pi()) + (90)::double precision) AS WINKEL, 
+        st_startpoint(ap.ORA_GEOMETRY) AS wkb_geometry 
  FROM ap_lpo ap 
  WHERE ((ap.signaturnummer = '2004') 
-   AND ('DKKM1000'::text ~~ ANY ((ap.advstandardmodell)::text[])));
+   AND ('DKKM1000' ~~ ANY ((ap.advstandardmodell)[])));
 CREATE OR REPLACE VIEW SK2012_FLURGRENZE 
 AS 
- SELECT fg.ogr_fid, fg.ora_geometry
+ SELECT fg.OGR_FID, fg.ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze fg
   WHERE (3000 = ANY (fg.artderflurstuecksgrenze)) 
-    AND fg.advstandardmodell ~~ 'DLKM'::text;
+    AND fg.advstandardmodell ~~ 'DLKM';
 COMMENT ON VIEW SK2012_FLURGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "Flurgrenze"';
 CREATE OR REPLACE VIEW SK2014_GEMARKUNGSGRENZE 
 AS 
- SELECT gemag.ogr_fid, gemag.ora_geometry
+ SELECT gemag.OGR_FID, gemag.ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze gemag
   WHERE (7003 = ANY (gemag.artderflurstuecksgrenze)) 
-    AND gemag.advstandardmodell ~~ 'DLKM'::text;
+    AND gemag.advstandardmodell ~~ 'DLKM';
 COMMENT ON VIEW SK2014_GEMARKUNGSGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "Gemarkungsgrenze"';
 CREATE OR REPLACE VIEW SK2018_BUNDESLANDGRENZE 
 AS 
- SELECT blg.ogr_fid, blg.ora_geometry
+ SELECT blg.OGR_FID, blg.ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze blg
   WHERE (7102 = ANY (blg.artderflurstuecksgrenze)) 
-    AND blg.advstandardmodell ~~ 'DLKM'::text;
-COMMENT ON VIEW SK2018_BUNDESLANDGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "Bundeslandgrenze"';
+    AND blg.advstandardmodell ~~ 'DLKM';
+COMMENT ON VIEW SK2018_BUNDESLANDGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "BundesLANDgrenze"';
 CREATE OR REPLACE VIEW SK2020_REGIERUNGSBEZIRKSGRENZE 
 AS 
- SELECT rbg.ogr_fid, rbg.ora_geometry
+ SELECT rbg.OGR_FID, rbg.ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze rbg
   WHERE (7103 = ANY (rbg.artderflurstuecksgrenze)) 
-    AND rbg.advstandardmodell ~~ 'DLKM'::text;
+    AND rbg.advstandardmodell ~~ 'DLKM';
 COMMENT ON VIEW SK2020_REGIERUNGSBEZIRKSGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "Regierungsbezirksgrenze"';
 CREATE OR REPLACE VIEW SK2022_GEMEINDEGRENZE 
 AS 
- SELECT gemg.ogr_fid, gemg.ora_geometry
+ SELECT gemg.OGR_FID, gemg.ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze gemg
   WHERE (7106 = ANY (gemg.artderflurstuecksgrenze)) 
-    AND gemg.advstandardmodell ~~ 'DLKM'::text;
+    AND gemg.advstandardmodell ~~ 'DLKM';
 COMMENT ON VIEW SK2022_GEMEINDEGRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze "Gemeindegrenze"';
 CREATE OR REPLACE VIEW SK201X_POLITISCHE_GRENZE 
 AS 
- SELECT ogr_fid, artderflurstuecksgrenze as art, ora_geometry
+ SELECT OGR_FID, artderflurstuecksgrenze as art, ORA_GEOMETRY
    FROM ax_besondereflurstuecksgrenze
   WHERE (7102 = ANY (artderflurstuecksgrenze) 
@@ -202,12 +202,12 @@
      OR  7106 = ANY (artderflurstuecksgrenze)
     )
-    AND advstandardmodell ~~ 'DLKM'::text;
-COMMENT ON VIEW SK201X_POLITISCHE_GRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze Politische Grenzen (Bund, Land, Kreis, Gemeinde)';
+    AND advstandardmodell ~~ 'DLKM';
+COMMENT ON VIEW SK201X_POLITISCHE_GRENZE IS 'fuer Kartendarstellung: besondere FlurstÃŒcksgrenze Politische Grenzen (Bund, LAND, Kreis, Gemeinde)';
 CREATE OR REPLACE VIEW FLSTNR_OHNE_POSITION
 AS 
- SELECT f.gml_id, 
-        f.gemarkungsnummer || '-' || f.flurnummer || '-' || f.zaehler::text || COALESCE ('/' || f.nenner::text, '') AS such
+ SELECT f.GL_ID, 
+        f.gemarkungsnummer || '-' || f.flurnummer || '-' || f.zaehler || COALESCE ('/' || f.nenner, '') AS SUCH
  FROM        ax_flurstueck     f 
-   LEFT JOIN alkis_beziehungen v  ON v.beziehung_zu = f.gml_id
+   LEFT JOIN alkis_beziehungen v  ON v.beziehung_zu = f.GL_ID
   WHERE v.beziehungsart is NULL
     AND f.endet IS NULL
@@ -216,8 +216,8 @@
 CREATE OR REPLACE VIEW S_ALLGEMEINE_TEXTE 
 AS 
- SELECT p.ogr_fid, 
-        p.art, 
-        p.drehwinkel * 57.296 AS drehwinkel,
-        p.schriftinhalt
+ SELECT p.OGR_FID, 
+        p.ART, 
+        p.DREHWINKEL * 57.296 AS DREHWINKEL,
+        p.SCHRIFTINHALT
    FROM ap_pto p
   WHERE NOT p.art = 'ZAE_NEN' 
@@ -233,5 +233,5 @@
 CREATE OR REPLACE VIEW TEXTE_MIT_UMBRUCH 
 AS 
- SELECT ogr_fid, schriftinhalt, art
+ SELECT OGR_FID, schriftinhalt, art
    FROM ap_pto 
   WHERE not schriftinhalt is null
@@ -242,8 +242,8 @@
    FROM s_allgemeine_texte;
 CREATE OR REPLACE VIEW FLURSTUECKS_MINMAX AS 
- SELECT min(st_xmin(ora_geometry)) AS r_min, 
-        min(st_ymin(ora_geometry)) AS h_min, 
-        max(st_xmax(ora_geometry)) AS r_max, 
-        max(st_ymax(ora_geometry)) AS h_max
+ SELECT min(st_xmin(ORA_GEOMETRY)) AS r_min, 
+        min(st_ymin(ORA_GEOMETRY)) AS h_min, 
+        max(st_xmax(ORA_GEOMETRY)) AS r_max, 
+        max(st_ymax(ORA_GEOMETRY)) AS h_max
    FROM ax_flurstueck f
    WHERE f.endet IS NULL;
@@ -251,7 +251,7 @@
 CREATE OR REPLACE VIEW BAURECHT
 AS
-  SELECT r.ogr_fid, 
-         r.ora_geometry, 
-         r.gml_id, 
+  SELECT r.OGR_FID, 
+         r.ORA_GEOMETRY, 
+         r.GL_ID, 
          r.artderfestlegung as adfkey,
          r."name",
@@ -264,5 +264,5 @@
       ON r.artderfestlegung = a.wert
     LEFT JOIN ax_dienststelle d
-      ON r.land   = d.land 
+      ON r.LAND   = d.LAND 
      AND r.stelle = d.stelle 
   WHERE r.endet IS NULL
@@ -271,17 +271,17 @@
 CREATE OR REPLACE VIEW GEMARKUNG_IN_GEMEINDE
 AS
-  SELECT DISTINCT land, regierungsbezirk, kreis, gemeinde, gemarkungsnummer
+  SELECT DISTINCT LAND, regierungsbezirk, kreis, gemeinde, gemarkungsnummer
   FROM            ax_flurstueck
   WHERE           endet IS NULL
-  ORDER BY        land, regierungsbezirk, kreis, gemeinde, gemarkungsnummer
+  ORDER BY        LAND, regierungsbezirk, kreis, gemeinde, gemarkungsnummer
 ;
 COMMENT ON VIEW GEMARKUNG_IN_GEMEINDE IS 'Welche Gemarkung liegt in welcher Gemeinde? Durch Verweise aus FlurstÃŒck.';
 CREATE OR REPLACE VIEW ARTEN_VON_FLURSTUECKSGEOMETRIE
 AS
- SELECT   count(gml_id) as anzahl,
-          st_geometrytype(ora_geometry)
+ SELECT   count(GL_ID) as anzahl,
+          st_geometrytype(ORA_GEOMETRY)
  FROM     ax_flurstueck
  WHERE    endet IS NULL
- GROUP BY st_geometrytype(ora_geometry);
+ GROUP BY st_geometrytype(ORA_GEOMETRY);
 CREATE OR REPLACE VIEW ADRESSEN_HAUSNUMMERN
 AS
@@ -289,5 +289,5 @@
         s.bezeichnung AS strassenname, 
          g.bezeichnung AS gemeindename, 
-         l.land, 
+         l.LAND, 
          l.regierungsbezirk, 
          l.kreis, 
@@ -317,7 +317,7 @@
       FROM   ax_flurstueck f 
       JOIN   alkis_beziehungen v 
-        ON f.gml_id=v.beziehung_von
+        ON f.GL_ID=v.beziehung_von
       JOIN   AX_LAGEBEZEICHNUNGMITHAUSNUMME l  
-        ON l.gml_id=v.beziehung_zu
+        ON l.GL_ID=v.beziehung_zu
       JOIN   ax_gemeinde g 
         ON l.kreis=g.kreis 
@@ -343,5 +343,5 @@
       f.nenner                     AS fs_nenner, 
       f.amtlicheflaeche            AS flaeche, 
-      f.ora_geometry               AS geom,
+      f.ORA_GEOMETRY               AS geom,
       b.bezeichnung                AS bezirkname,
       g.BUCHUNGSBLATTNUMMERMITBUCHSTAB AS gb_blatt, 
@@ -352,15 +352,15 @@
       p.nachnameoderfirma          AS nachname
    FROM       ax_person              p
-        JOIN  alkis_beziehungen      bpn  ON bpn.beziehung_zu  = p.gml_id 
-        JOIN  ax_namensnummer        n    ON bpn.beziehung_von =n.gml_id 
-        JOIN  alkis_beziehungen      bng  ON n.gml_id = bng.beziehung_von 
-        JOIN  ax_buchungsblatt       g    ON bng.beziehung_zu = g.gml_id 
-        JOIN  ax_buchungsblattbezirk b    ON g.land = b.land AND g.bezirk = b.bezirk 
-        JOIN  alkis_beziehungen      bgs  ON bgs.beziehung_zu = g.gml_id 
-        JOIN  ax_buchungsstelle      s    ON s.gml_id = bgs.beziehung_von 
+        JOIN  alkis_beziehungen      bpn  ON bpn.beziehung_zu  = p.GL_ID 
+        JOIN  ax_namensnummer        n    ON bpn.beziehung_von =n.GL_ID 
+        JOIN  alkis_beziehungen      bng  ON n.GL_ID = bng.beziehung_von 
+        JOIN  ax_buchungsblatt       g    ON bng.beziehung_zu = g.GL_ID 
+        JOIN  ax_buchungsblattbezirk b    ON g.LAND = b.LAND AND g.bezirk = b.bezirk 
+        JOIN  alkis_beziehungen      bgs  ON bgs.beziehung_zu = g.GL_ID 
+        JOIN  ax_buchungsstelle      s    ON s.GL_ID = bgs.beziehung_von 
         JOIN  ax_buchungsstelle_buchungsart art ON s.buchungsart = art.wert 
-        JOIN  alkis_beziehungen      bsf  ON bsf.beziehung_zu = s.gml_id
-        JOIN  ax_flurstueck          f    ON f.gml_id = bsf.beziehung_von 
-        JOIN  ax_gemarkung           k    ON f.land = k.land AND f.gemarkungsnummer = k.gemarkungsnummer 
+        JOIN  alkis_beziehungen      bsf  ON bsf.beziehung_zu = s.GL_ID
+        JOIN  ax_flurstueck          f    ON f.GL_ID = bsf.beziehung_von 
+        JOIN  ax_gemarkung           k    ON f.LAND = k.LAND AND f.gemarkungsnummer = k.gemarkungsnummer 
    WHERE p.nachnameoderfirma LIKE 'Gemeinde %'
      AND bpn.beziehungsart = 'benennt'
@@ -393,5 +393,5 @@
       f.nenner                     AS fs_nenner, 
       f.amtlicheflaeche            AS flaeche, 
-      f.ora_geometry               AS geom,
+      f.ORA_GEOMETRY               AS geom,
       b.bezeichnung                AS bezirkname,
       g.BUCHUNGSBLATTNUMMERMITBUCHSTAB AS gb_blatt, 
@@ -405,18 +405,18 @@
       p.nachnameoderfirma          AS nachname
    FROM       ax_person              p
-        JOIN  alkis_beziehungen      bpn  ON bpn.beziehung_zu  = p.gml_id 
-        JOIN  ax_namensnummer        n    ON bpn.beziehung_von =n.gml_id 
-        JOIN  alkis_beziehungen      bng  ON n.gml_id = bng.beziehung_von 
-        JOIN  ax_buchungsblatt       g    ON bng.beziehung_zu = g.gml_id 
-        JOIN  ax_buchungsblattbezirk b    ON g.land = b.land AND g.bezirk = b.bezirk 
-        JOIN  alkis_beziehungen      bgs  ON bgs.beziehung_zu = g.gml_id 
-        JOIN  ax_buchungsstelle      sh   ON sh.gml_id = bgs.beziehung_von
+        JOIN  alkis_beziehungen      bpn  ON bpn.beziehung_zu  = p.GL_ID 
+        JOIN  ax_namensnummer        n    ON bpn.beziehung_von =n.GL_ID 
+        JOIN  alkis_beziehungen      bng  ON n.GL_ID = bng.beziehung_von 
+        JOIN  ax_buchungsblatt       g    ON bng.beziehung_zu = g.GL_ID 
+        JOIN  ax_buchungsblattbezirk b    ON g.LAND = b.LAND AND g.bezirk = b.bezirk 
+        JOIN  alkis_beziehungen      bgs  ON bgs.beziehung_zu = g.GL_ID 
+        JOIN  ax_buchungsstelle      sh   ON sh.GL_ID = bgs.beziehung_von
         JOIN  ax_buchungsstelle_buchungsart arth ON sh.buchungsart = arth.wert 
-        JOIN  alkis_beziehungen      bss  ON sh.gml_id = bss.beziehung_von
-        JOIN  ax_buchungsstelle      sd   ON sd.gml_id = bss.beziehung_zu
+        JOIN  alkis_beziehungen      bss  ON sh.GL_ID = bss.beziehung_von
+        JOIN  ax_buchungsstelle      sd   ON sd.GL_ID = bss.beziehung_zu
         JOIN  ax_buchungsstelle_buchungsart artd ON sd.buchungsart = artd.wert 
-        JOIN  alkis_beziehungen      bsf  ON bsf.beziehung_zu = sd.gml_id
-        JOIN  ax_flurstueck          f    ON f.gml_id = bsf.beziehung_von 
-        JOIN  ax_gemarkung           k    ON f.land = k.land AND f.gemarkungsnummer = k.gemarkungsnummer 
+        JOIN  alkis_beziehungen      bsf  ON bsf.beziehung_zu = sd.GL_ID
+        JOIN  ax_flurstueck          f    ON f.GL_ID = bsf.beziehung_von 
+        JOIN  ax_gemarkung           k    ON f.LAND = k.LAND AND f.gemarkungsnummer = k.gemarkungsnummer 
    WHERE p.nachnameoderfirma LIKE 'Stadt %'
      AND bpn.beziehungsart = 'benennt'
@@ -447,10 +447,10 @@
  FROM alkis_beziehungen AS bezalt
  WHERE EXISTS
-       (SELECT ogr_fid
+       (SELECT OGR_FID
          FROM alkis_beziehungen AS bezneu
         WHERE bezalt.beziehung_von = bezneu.beziehung_von
           AND bezalt.beziehung_zu  = bezneu.beziehung_zu
           AND bezalt.beziehungsart = bezneu.beziehungsart
-          AND bezalt.ogr_fid       < bezneu.ogc_fid
+          AND bezalt.OGR_FID       < bezneu.ogc_fid
         );
 COMMENT ON VIEW BEZIEHUNGEN_REDUNDANT IS 'alkis_beziehungen zu denen es eine identische neue Version gibt.';
@@ -460,13 +460,13 @@
  FROM alkis_beziehungen AS bezalt
  WHERE EXISTS
-       (SELECT ogr_fid
+       (SELECT OGR_FID
          FROM alkis_beziehungen AS bezneu
         WHERE bezalt.beziehung_von = bezneu.beziehung_von
           AND bezalt.beziehung_zu  = bezneu.beziehung_zu
           AND bezalt.beziehungsart = bezneu.beziehungsart
-          AND bezalt.ogr_fid       < bezneu.ogc_fid
+          AND bezalt.OGR_FID       < bezneu.ogc_fid
         )
      AND EXISTS
-        (SELECT ogr_fid
+        (SELECT OGR_FID
          FROM delete
          WHERE bezalt.beziehung_von = substr(featureid, 1, 16)
