drop view wsnhrn_complete;

create view wsnhrn_complete
            (id, geom, r_name, r_nummer, rb_groesse, "table", floor, rb_ebene, rb_haus, r_public, rb_revier, rb_belag,
             rb_turnus, rb_status, r_cat)
as
SELECT "WSNHRN_UG01_POLY".id,
       "WSNHRN_UG01_POLY".geom,
       "WSNHRN_UG01_POLY".r_name,
       "WSNHRN_UG01_POLY".r_nummer,
       "WSNHRN_UG01_POLY".rb_groesse,
       'public.WSNHRN_UG01_POLY'::text AS "table",
        '-1'::text                      AS floor,
        '-1'::text                      AS rb_ebene,
        "WSNHRN_UG01_POLY".rb_haus,
       "WSNHRN_UG01_POLY".r_public,
       "WSNHRN_UG01_POLY".rb_revier,
       "WSNHRN_UG01_POLY".rb_belag,
       "WSNHRN_UG01_POLY".rb_turnus,
       "WSNHRN_UG01_POLY".rb_status,
       "WSNHRN_UG01_POLY".r_cat
FROM "WSNHRN_UG01_POLY"
UNION ALL
SELECT "WSNHRN_EG00_POLY".id,
       "WSNHRN_EG00_POLY".geom,
       "WSNHRN_EG00_POLY".r_name,
       "WSNHRN_EG00_POLY".r_nummer,
       "WSNHRN_EG00_POLY".rb_groesse,
       'public.WSNHRN_EG00_POLY'::text AS "table",
        '0'::text                       AS floor,
        '0'::text                       AS rb_ebene,
        "WSNHRN_EG00_POLY".rb_haus,
       "WSNHRN_EG00_POLY".r_public,
       "WSNHRN_EG00_POLY".rb_revier,
       "WSNHRN_EG00_POLY".rb_belag,
       "WSNHRN_EG00_POLY".rb_turnus,
       "WSNHRN_EG00_POLY".rb_status,
       "WSNHRN_EG00_POLY".r_cat
FROM "WSNHRN_EG00_POLY"
UNION ALL
SELECT "WSNHRN_OG01_POLY".id,
       "WSNHRN_OG01_POLY".geom,
       "WSNHRN_OG01_POLY".r_name,
       "WSNHRN_OG01_POLY".r_nummer,
       "WSNHRN_OG01_POLY".rb_groesse,
       'public.WSNHRN_OG01_POLY'::text AS "table",
        '1'::text                       AS floor,
        '1'::text                       AS rb_ebene,
        "WSNHRN_OG01_POLY".rb_haus,
       "WSNHRN_OG01_POLY".r_public,
       "WSNHRN_OG01_POLY".rb_revier,
       "WSNHRN_OG01_POLY".rb_belag,
       "WSNHRN_OG01_POLY".rb_turnus,
       "WSNHRN_OG01_POLY".rb_status,
       "WSNHRN_OG01_POLY".r_cat
FROM "WSNHRN_OG01_POLY"
UNION ALL
SELECT "WSNHRN_OG02_POLY".id,
       "WSNHRN_OG02_POLY".geom,
       "WSNHRN_OG02_POLY".r_name,
       "WSNHRN_OG02_POLY".r_nummer,
       "WSNHRN_OG02_POLY".rb_groesse,
       'public.WSNHRN_OG02_POLY'::text AS "table",
        '2'::text                       AS floor,
        '2'::text                       AS rb_ebene,
        "WSNHRN_OG02_POLY".rb_haus,
       "WSNHRN_OG02_POLY".r_public,
       "WSNHRN_OG02_POLY".rb_revier,
       "WSNHRN_OG02_POLY".rb_belag,
       "WSNHRN_OG02_POLY".rb_turnus,
       "WSNHRN_OG02_POLY".rb_status,
       "WSNHRN_OG02_POLY".r_cat
FROM "WSNHRN_OG02_POLY"
UNION ALL
SELECT "WSNHRN_OG03_POLY".id,
       "WSNHRN_OG03_POLY".geom,
       "WSNHRN_OG03_POLY".r_name,
       "WSNHRN_OG03_POLY".r_nummer,
       "WSNHRN_OG03_POLY".rb_groesse,
       'public.WSNHRN_OG03_POLY'::text AS "table",
        '3'::text                       AS floor,
        '3'::text                       AS rb_ebene,
        "WSNHRN_OG03_POLY".rb_haus,
       "WSNHRN_OG03_POLY".r_public,
       "WSNHRN_OG03_POLY".rb_revier,
       "WSNHRN_OG03_POLY".rb_belag,
       "WSNHRN_OG03_POLY".rb_turnus,
       "WSNHRN_OG03_POLY".rb_status,
       "WSNHRN_OG03_POLY".r_cat
FROM "WSNHRN_OG03_POLY"
UNION ALL
SELECT "WSNHRN_OG04_POLY".id,
       "WSNHRN_OG04_POLY".geom,
       "WSNHRN_OG04_POLY".r_name,
       "WSNHRN_OG04_POLY".r_nummer,
       "WSNHRN_OG04_POLY".rb_groesse,
       'public.WSNHRN_OG04_POLY'::text AS "table",
        '4'::text                       AS floor,
        '4'::text                       AS rb_ebene,
        "WSNHRN_OG04_POLY".rb_haus,
       "WSNHRN_OG04_POLY".r_public,
       "WSNHRN_OG04_POLY".rb_revier,
       "WSNHRN_OG04_POLY".rb_belag,
       "WSNHRN_OG04_POLY".rb_turnus,
       "WSNHRN_OG04_POLY".rb_status,
       "WSNHRN_OG04_POLY".r_cat
FROM "WSNHRN_OG04_POLY";


