GLE-Layer-Baumkataster

Aus kvwmap
Wechseln zu: Navigation, Suche
SET @group_id = 1;
SET @connection_id = 1;

# Layer Baumkataster Dokumente
INSERT INTO layer (`Name`,`Datentyp`,`Gruppe`,`pfad`,`Data`,`schema`,`document_path`,`tileindex`,`tileitem`,`labelangleitem`,`labelitem`,`labelmaxscale`,`labelminscale`,`labelrequires`,`connection_id`,`printconnection`,`connectiontype`,`classitem`,`tolerance`,`toleranceunits`,`epsg_code`,`template`,`queryable`,`transparency`,`drawingorder`,`minscale`,`maxscale`,`offsite`,`ows_srs`,`wms_name`,`wms_server_version`,`wms_format`,`wms_connectiontimeout`,`wms_auth_username`,`wms_auth_password`,`wfs_geom`,`selectiontype`,`querymap`,`logconsume`,`processing`,`kurzbeschreibung`,`datenherr`,`metalink`,`privileg`) VALUES('Baumkataster Dokumente','5',@group_id,'SELECT kontrollid, dokument FROM  kontrollen_docs WHERE (1=1)','','baumkataster','','','','','',NULL,NULL,'',@connection_id,'','6','kontrollid','10','pixels','25833','','1','100',NULL,'-1','-1','','EPSG:2398','','1.1.0','image/png','60','','','','','0','0','','','Gemeinde Ahnatal','','2');
SET @last_layer_id26=LAST_INSERT_ID();
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id26,'dokument','dokument','kontrollen_docs','kontrollen_docs','varchar','','','0','255','Dokument','','Dokument','','1','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id26,'kontrollid','kontrollid','kontrollen_docs','kontrollen_docs','int4','','','0',NULL,'Text','','Kontroll-ID','','0','0');
UPDATE layer_attributes SET options = REPLACE(options, '26', @last_layer_id26) WHERE layer_id IN(@last_layer_id26) AND form_element_type IN ('SubFormPK', 'SubFormFK', 'SubFormEmbeddedPK');

# Layer Baumkataster Grunddaten
INSERT INTO layer (`Name`,`Datentyp`,`Gruppe`,`pfad`,`Data`,`schema`,`document_path`,`tileindex`,`tileitem`,`labelangleitem`,`labelitem`,`labelmaxscale`,`labelminscale`,`labelrequires`,`connection_id`,`printconnection`,`connectiontype`,`classitem`,`tolerance`,`toleranceunits`,`epsg_code`,`template`,`queryable`,`transparency`,`drawingorder`,`minscale`,`maxscale`,`offsite`,`ows_srs`,`wms_name`,`wms_server_version`,`wms_format`,`wms_connectiontimeout`,`wms_auth_username`,`wms_auth_password`,`wfs_geom`,`selectiontype`,`querymap`,`logconsume`,`processing`,`kurzbeschreibung`,`datenherr`,`metalink`,`privileg`) VALUES('Baumkataster Grunddaten','0',@group_id,'SELECT baumid, baumnummer, amt, gemeinde, standort, status, baumart, baumart_spezial, sorte, sicherheitserwartung, kontrollintervall, \'anzeigen ->\' AS kontrolle, \'http://www.justiz.nrw.de/nrwe/olgs/koeln/j2010/7_U_31_10urteil20100729.html\' as link_urteil, bearbeiter, the_geom FROM grunddaten_baum WHERE (1=1)','the_geom from baumkataster.grunddaten_baum as foo using unique oid using srid=25833','baumkataster','','','','','baumnummer','5001','99','',@connection_id,'','6','baumid','10','pixels','25833','','1','100','91000','99','15001','','EPSG:2398','','1.1.0','image/png','60','','','','','1','0','','','Gemeinde Ahnatal','','2');
SET @last_layer_id27=LAST_INSERT_ID();

INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'amt','amt','grunddaten_baum','grunddaten_baum','varchar','','','1','100','Auswahlfeld','select distinct amt as value, amt as output from gd_gemeinde_amt order by amt <required by>gemeinde</required by>','Amt','','2','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'baumart','baumart','grunddaten_baum','grunddaten_baum','varchar','','','1','255','Auswahlfeld','select bezeichnunglatein as value, bezeichnunglatein||\' - \'||bezeichnung as output from baumkataster.baumarten order by bezeichnunglatein','Baumart','','6','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'baumart_spezial','baumart_spezial','grunddaten_baum','grunddaten_baum','varchar','','','1','255','Text','','Baumart (sonstige)','Falls nicht in der Liste enthalten','7','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'baumid','baumid','grunddaten_baum','grunddaten_baum','int4','','PRIMARY KEY','1','32','Text','','Baum-ID','','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'baumnummer','baumnummer','grunddaten_baum','grunddaten_baum','int4','','','0','32','Text','','Baum-Nummer','','1','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'bearbeiter','bearbeiter','grunddaten_baum','grunddaten_baum','varchar','','','0','100','User','','Bearbeiter','Name des Bearbeiters, der die Daten eingetragen hat. Diese Angabe wird automatisch durch das Programm gesetzt.','13','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'gemeinde','gemeinde','grunddaten_baum','grunddaten_baum','varchar','','','1','100','Auswahlfeld','select gemeindename as value, gemeindename as output from public.gd_gemeinde_amt  as a where a.amt = <requires>amt</requires> order by gemeindename','Gemeinde','','3','1');

INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'kontrollintervall','kontrollintervall','grunddaten_baum','grunddaten_baum','varchar','','','0','50','Auswahlfeld','\'halbjährlich\',\'jährlich\',\'alle 2 Jahre\',\'alle 3 Jahre\',\'Überprüfung bei Jungbaumpflege\'','Kontrollintervall','siehe Tabelle 1 im Kapitel 5.3.2.2 der Baumkontrollrichtlinie (2010)','10','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'link_urteil','link_urteil','','','unknown','','',NULL,NULL,'Link','','Rechtliche Grundlagen','','12','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'sicherheitserwartung','sicherheitserwartung','grunddaten_baum','grunddaten_baum','varchar','','','0','10','Auswahlfeld','\'geringer\',\'höher\'','Sicherheitserwartung Verkehr','siehe Kapitel 5.2.1 der Baumkontrollrichtlinie (2010)','9','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'sorte','sorte','grunddaten_baum','grunddaten_baum','varchar','','','1','50','Text','','Sorte','','8','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'standort','standort','grunddaten_baum','grunddaten_baum','varchar','','','1','255','Text','','Standort','Straße oder Lagebezeichnung','4','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'status','status','grunddaten_baum','grunddaten_baum','varchar','','','0','10','Auswahlfeld','\'vorhanden\',\'gefällt\'','Status','Baum vorhanden oder gefällt','5','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'the_geom','the_geom','grunddaten_baum','grunddaten_baum','geometry','POINT','','1',NULL,'Geometrie','','','','14','1');
INSERT INTO classes (`Name`,`Layer_ID`,`Expression`,`drawingorder`,`text`) VALUES('gefällt',@last_layer_id27,'(\'[status]\' eq \'gefällt\')','2','');
 SET @last_class_id=LAST_INSERT_ID();
INSERT INTO styles (`symbol`,`symbolname`,`size`,`color`,`backgroundcolor`,`outlinecolor`,`minsize`,`maxsize`,`angle`,`angleitem`,`antialias`,`width`,`minwidth`,`maxwidth`) VALUES(NULL,'punkt','14','225 207 167','','225 207 167','6','20',NULL,'',NULL,NULL,NULL,NULL);
 SET @last_style_id=LAST_INSERT_ID();
INSERT INTO u_styles2classes (style_id, class_id, drawingorder) VALUES (@last_style_id, @last_class_id, 0);
INSERT INTO styles (`symbol`,`symbolname`,`size`,`color`,`backgroundcolor`,`outlinecolor`,`minsize`,`maxsize`,`angle`,`angleitem`,`antialias`,`width`,`minwidth`,`maxwidth`) VALUES(NULL,'kreuz_gefaellt','14','188 0 42','','255 255 255','6','20','360','',NULL,NULL,NULL,NULL);
 SET @last_style_id=LAST_INSERT_ID();
INSERT INTO u_styles2classes (style_id, class_id, drawingorder) VALUES (@last_style_id, @last_class_id, 1);
INSERT INTO classes (`Name`,`Layer_ID`,`Expression`,`drawingorder`,`text`) VALUES(' vorhanden',@last_layer_id27,'(\'[status]\' eq \'vorhanden\')','1','');
SET @last_class_id=LAST_INSERT_ID();
INSERT INTO styles (`symbol`,`symbolname`,`size`,`color`,`backgroundcolor`,`outlinecolor`,`minsize`,`maxsize`,`angle`,`angleitem`,`antialias`,`width`,`minwidth`,`maxwidth`) VALUES(NULL,'punkt','21','0 0 0','','-1 -1 -1','11','31',NULL,'',NULL,NULL,NULL,NULL);
 SET @last_style_id=LAST_INSERT_ID();
INSERT INTO u_styles2classes (style_id, class_id, drawingorder) VALUES (@last_style_id, @last_class_id, 0);
INSERT INTO styles (`symbol`,`symbolname`,`size`,`color`,`backgroundcolor`,`outlinecolor`,`minsize`,`maxsize`,`angle`,`angleitem`,`antialias`,`width`,`minwidth`,`maxwidth`) VALUES(NULL,'punkt','20','76 159 0','','-1 -1 -1','10','30',NULL,'',NULL,NULL,NULL,NULL);
 SET @last_style_id=LAST_INSERT_ID();
INSERT INTO u_styles2classes (style_id, class_id, drawingorder) VALUES (@last_style_id, @last_class_id, 1);
INSERT INTO styles (`symbol`,`symbolname`,`size`,`color`,`backgroundcolor`,`outlinecolor`,`minsize`,`maxsize`,`angle`,`angleitem`,`antialias`,`width`,`minwidth`,`maxwidth`) VALUES(NULL,'punkt','2','255 255 255','','-1 -1 -1','0','8',NULL,'',NULL,NULL,NULL,NULL);
 SET @last_style_id=LAST_INSERT_ID();
INSERT INTO u_styles2classes (style_id, class_id, drawingorder) VALUES (@last_style_id, @last_class_id, 2);
INSERT INTO labels (`font`,`type`,`color`,`outlinecolor`,`shadowcolor`,`shadowsizex`,`shadowsizey`,`backgroundcolor`,`backgroundshadowcolor`,`backgroundshadowsizex`,`backgroundshadowsizey`,`size`,`minsize`,`maxsize`,`position`,`offsetx`,`offsety`,`angle`,`autoangle`,`buffer`,`antialias`,`minfeaturesize`,`maxfeaturesize`,`partials`,`wrap`,`the_force`) VALUES('courier',NULL,'40 40 40','255 255 255','',NULL,NULL,'','',NULL,NULL,'8','8','8',NULL,'10','-10',NULL,NULL,NULL,'1',NULL,NULL,NULL,NULL,'1');
 SET @last_label_id=LAST_INSERT_ID();
INSERT INTO u_labels2classes (label_id, class_id) VALUES (@last_label_id, @last_class_id);
UPDATE layer_attributes SET options = REPLACE(options, '27', @last_layer_id27) WHERE layer_id IN(@last_layer_id27) AND form_element_type IN ('SubFormPK', 'SubFormFK', 'SubFormEmbeddedPK');
# Layer Baumkataster Kontrolldaten
INSERT INTO layer (`Name`,`Datentyp`,`Gruppe`,`pfad`,`Data`,`schema`,`document_path`,`tileindex`,`tileitem`,`labelangleitem`,`labelitem`,`labelmaxscale`,`labelminscale`,`labelrequires`,`connection_id`,`printconnection`,`connectiontype`,`classitem`,`tolerance`,`toleranceunits`,`epsg_code`,`template`,`queryable`,`transparency`,`drawingorder`,`minscale`,`maxscale`,`offsite`,`ows_srs`,`wms_name`,`wms_server_version`,`wms_format`,`wms_connectiontimeout`,`wms_auth_username`,`wms_auth_password`,`wfs_geom`,`selectiontype`,`querymap`,`logconsume`,`processing`,`kurzbeschreibung`,`datenherr`,`metalink`,`privileg`) VALUES('Baumkataster Kontrolldaten','5',@group_id,'SELECT kontrollid, k.baumid, baumnummer, datum, kontrollart, g.bearbeiter, baumhoehe, kronendurchmesser, stammumfang, alteramstandort, entwicklungsphase, CASE WHEN (select k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 + k14 + k15 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + wu1 + wu2 + wu3 + v1 + v2 + v3 + v4 + v5 + v6 from regelkontrollen rk where rk.kontrollid=k.kontrollid) = 0 THEN \'Kein Eintrag\' WHEN (select k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 + k14 + k15 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + wu1 + wu2 + wu3 + v1 + v2 + v3 + v4 + v5 + v6 from regelkontrollen rk where rk.kontrollid=k.kontrollid) = 1 THEN \'1 Eintrag\' ELSE (select k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 + k11 + k12 + k13 + k14 + k15 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 + s13 + s14 + w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + wu1 + wu2 + wu3 + v1 + v2 + v3 + v4 + v5 + v6 from regelkontrollen rk where rk.kontrollid=k.kontrollid) || \' Einträge\' END AS regelkontrollen, zustand, handlungsbedarf, bemerkung, \'anzeigen\' AS dokument FROM kontrollen k, grunddaten_baum g WHERE g.baumid=k.baumid ORDER BY datum','','baumkataster','','','','','',NULL,NULL,'',@connection_id,'','6','kontrollid','10','pixels','25833','','1','100',NULL,'-1','-1','','EPSG:2398','','1.1.0','image/png','60','','','','','0','0','','','Gemeinde Ahnatal','','2');
SET @last_layer_id28=LAST_INSERT_ID();

-- Erst hier, weil erst hier die Layer-ID für das Verknüpfungsattribut bekannt ist.
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id27,'kontrolle','kontrolle','','','unknown','','',NULL,NULL,'SubFormEmbeddedPK','@last_layer_id28,baumid,datum;no_new_window','Kontrolldaten','','11','1');

INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'alteramstandort','alteramstandort','kontrollen','k','int2','','','1','16','Text','','Alter (am Standort)','','9','1');

INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'baumhoehe','baumhoehe','kontrollen','k','int2','','','1','16','Text','','Baumhöhe [m]','Angaben in Metern','6','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'baumid','baumid','kontrollen','k','int4','','','0','32','Text','','Baum-ID','','1','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'baumnummer','baumnummer','grunddaten_baum','g','int4','','','0','32','SubFormFK','27,baumid;no_new_window','Baumnummer','','2','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'bearbeiter','bearbeiter','grunddaten_baum','g','varchar','','','0','100','Text','','Bearbeiter','','5','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'bemerkung','bemerkung','kontrollen','k','text','','','1',NULL,'Textfeld','','Bemerkungen','Bemerkungen zum Handlungsbedarf','14','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'datum','datum','kontrollen','k','date','','','0',NULL,'Text','','Datum der Kontrolle','','3','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'dokument','dokument','','','unknown','','',NULL,NULL,'SubFormEmbeddedPK','@last_layer_id26,kontrollid,dokument;no_new_window','Dokumente','','15','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'entwicklungsphase','entwicklungsphase','kontrollen','k','varchar','','','1','20','Auswahlfeld','select bezeichnung as value, text as output from entwicklungsphasen order by id','Entwicklungsphase','siehe Kapitel 5.2.3.1 der Baumkontrollrichtlinie (2010)','10','1');

INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'kontrollart','kontrollart','kontrollen','k','varchar','','','0','20','Auswahlfeld','\'Ersterfassung\',\'Regelkontrolle\'','Kontrollart','','4','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'kontrollid','kontrollid','kontrollen','k','int4','','PRIMARY KEY','1','32','Text','','Kontroll-ID','','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'kronendurchmesser','kronendurchmesser','kontrollen','k','int2','','','1','16','Text','','Kronendurchmesser [m]','Angaben in Metern','7','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'regelkontrollen','regelkontrollen','','','text','','',NULL,NULL,'SubFormPK','30,kontrollid;no_new_window','Regelkontrolle','','11','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'stammumfang','stammumfang','kontrollen','k','numeric','','','1',NULL,'Text','','Stammumfang [m] (in 1 m Höhe)','Angaben in Metern, Nachkomma möglich','8','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'zustand','zustand','kontrollen','k','varchar','','','1','50','Auswahlfeld','\'gesund / leicht geschädigt\',\'stark geschädigt\'','Zustand','Allg. Einschätzung des Baumzustandes bez. der Stand- und Bruchsicherheit des Baumes','12','1');
UPDATE layer_attributes SET options = REPLACE(options, '28', @last_layer_id28) WHERE layer_id IN(@last_layer_id28) AND form_element_type IN ('SubFormPK', 'SubFormFK', 'SubFormEmbeddedPK');

# Layer Baumkataster Kontrolle Handlungsbedarf
INSERT INTO layer (`Name`,`Datentyp`,`Gruppe`,`pfad`,`Data`,`schema`,`document_path`,`tileindex`,`tileitem`,`labelangleitem`,`labelitem`,`labelmaxscale`,`labelminscale`,`labelrequires`,`connection_id`,`printconnection`,`connectiontype`,`classitem`,`tolerance`,`toleranceunits`,`epsg_code`,`template`,`queryable`,`transparency`,`drawingorder`,`minscale`,`maxscale`,`offsite`,`ows_srs`,`wms_name`,`wms_server_version`,`wms_format`,`wms_connectiontimeout`,`wms_auth_username`,`wms_auth_password`,`wfs_geom`,`selectiontype`,`querymap`,`logconsume`,`processing`,`kurzbeschreibung`,`datenherr`,`metalink`,`privileg`) VALUES('Baumkataster Kontrolle Handlungsbedarf','5',@group_id,'SELECT k.kontrollid, \'(\' || k.kontrollid || \') \' || k.datum as zurueck, b.amt, b.gemeinde, b.standort, b.baumnummer, handlungsbedarf, eingehendeuntersuchung, massnahme, massnahmeart, faellung, erledigung FROM kontrollen k, grunddaten_baum b WHERE k.baumid=b.baumid','','baumkataster','','','','','',NULL,NULL,'',@connection_id,'','6','kontrollid','10','pixels','25833','','1','100',NULL,'-1','-1','','EPSG:2398','','1.1.0','image/png','60','','','','','0','0','','','Gemeinde Ahnatal','','0');
SET @last_layer_id29=LAST_INSERT_ID();

# Erst hier weil jetzt erst die layer_id vom Layer bekannt ist für die Verknüpfung.
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id28,'handlungsbedarf','handlungsbedarf','kontrollen','k','varchar','','','0','4','SubFormEmbeddedPK','@last_layer_id29,kontrollid,handlungsbedarf;embedded','Handlungsbedarf','','13','0');


INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'eingehendeuntersuchung','eingehendeuntersuchung','kontrollen','kontrollen','varchar','','','0','4','Auswahlfeld','\'ja\',\'-\'','eingehende Untersuchung','z.B. Untersuchung auf Fäulen, Erstellung Baumgutachten','3','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'erledigung','erledigung','kontrollen','kontrollen','varchar','','','0','50','Auswahlfeld','\'sofort\',\'innerhalb von 2 Wochen\',\'innerhalb von 6 Monaten\',\'innerhalb der nächsten 2 Jahre\',\'-\'','Erledigung','siehe Kapitel 5.3.2.3 der Baumkontrollrichtlinie (2010)','7','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'faellung','faellung','kontrollen','kontrollen','varchar','','','0','4','Auswahlfeld','\'ja\',\'nein\'','Fällung','','6','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'handlungsbedarf','handlungsbedarf','kontrollen','kontrollen','varchar','','','0','4','Auswahlfeld','\'ja\',\'nein\'','Handlungsbedarf','','2','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'kontrollid','kontrollid','kontrollen','kontrollen','int4','','PRIMARY KEY','1','32','Text','','Kontroll-ID','','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'massnahme','massnahme','kontrollen','kontrollen','varchar','','','0','4','Auswahlfeld','\'ja\',\'-\'','Baumpflegerische Maßnahme','','4','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'massnahmeart','massnahmeart','kontrollen','kontrollen','varchar','','','1','50','Auswahlfeld','select bezeichnung as value, bezeichnung as output from baumkataster.massnahmearten order by bezeichnung','Art der Maßnahme','','5','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id29,'zurueck','zurueck','','','text','','',NULL,NULL,'SubFormFK','28,kontrollid;no_new_window','zur Kontrolle','','1','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`decimal_length`,`default`,`form_element_type`,`options`,`alias`,`alias_low-german`,`alias_english`,`alias_polish`,`alias_vietnamese`,`tooltip`,`group`,`raster_visibility`,`mandatory`,`order`,`privileg`,`query_tooltip`) VALUES(@last_layer_id29,'amt','amt','grunddaten_baum','b','varchar','','','1','100',NULL,'','Text','','Amt','','','','','','Grunddaten',NULL,NULL,'0','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`decimal_length`,`default`,`form_element_type`,`options`,`alias`,`alias_low-german`,`alias_english`,`alias_polish`,`alias_vietnamese`,`tooltip`,`group`,`raster_visibility`,`mandatory`,`order`,`privileg`,`query_tooltip`) VALUES(@last_layer_id29,'gemeinde','gemeinde','grunddaten_baum','b','varchar','','','1','100',NULL,'','Text','','Gemeinde','','','','','','Grunddaten',NULL,NULL,'1','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`decimal_length`,`default`,`form_element_type`,`options`,`alias`,`alias_low-german`,`alias_english`,`alias_polish`,`alias_vietnamese`,`tooltip`,`group`,`raster_visibility`,`mandatory`,`order`,`privileg`,`query_tooltip`) VALUES(@last_layer_id29,'standort','standort','grunddaten_baum','b','varchar','','','1','255',NULL,'','Text','','Standort','','','','','','Grunddaten',NULL,NULL,'2','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`decimal_length`,`default`,`form_element_type`,`options`,`alias`,`alias_low-german`,`alias_english`,`alias_polish`,`alias_vietnamese`,`tooltip`,`group`,`raster_visibility`,`mandatory`,`order`,`privileg`,`query_tooltip`) VALUES(@last_layer_id29,'baumnummer','baumnummer','grunddaten_baum','b','int4','','','0','32',NULL,'','Text','','Baumnummer','','','','','','Grunddaten',NULL,NULL,'3','0','0');
UPDATE layer_attributes SET options = REPLACE(options, '29', @last_layer_id29) WHERE layer_id IN(@last_layer_id29) AND form_element_type IN ('SubFormPK', 'SubFormFK', 'SubFormEmbeddedPK');

# Layer Baumkataster Regelkontrollen
INSERT INTO layer (`Name`,`Datentyp`,`Gruppe`,`pfad`,`Data`,`schema`,`document_path`,`tileindex`,`tileitem`,`labelangleitem`,`labelitem`,`labelmaxscale`,`labelminscale`,`labelrequires`,`connection_id`,`printconnection`,`connectiontype`,`classitem`,`tolerance`,`toleranceunits`,`epsg_code`,`template`,`queryable`,`transparency`,`drawingorder`,`minscale`,`maxscale`,`offsite`,`ows_srs`,`wms_name`,`wms_server_version`,`wms_format`,`wms_connectiontimeout`,`wms_auth_username`,`wms_auth_password`,`wfs_geom`,`selectiontype`,`querymap`,`logconsume`,`processing`,`kurzbeschreibung`,`datenherr`,`metalink`,`privileg`) VALUES('Baumkataster Regelkontrolle','5',@group_id,'SELECT r.kontrollid, \'(\' || r.kontrollid || \') \' || k.datum as zurueck, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15, bemerkungen_krone, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, bemerkungen_stamm, w1, w2, w3, w4, w5, w6, w7, w8, bemerkungen_stammfuss, wu1, wu2, wu3, bemerkungen_wurzel, v1, v2, v3, v4, v5, v6, bemerkungen_umfeld FROM kontrollen k, regelkontrollen r WHERE k.kontrollid=r.kontrollid','','baumkataster','','','','','',NULL,NULL,'',@connection_id,'','6','kontrollid','10','pixels','25833','','1','100',NULL,'-1','-1','','EPSG:2398','','1.1.0','image/png','60','','','','','0','0','','','Gemeinde Ahnatal','','0');
SET @last_layer_id30=LAST_INSERT_ID();
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'bemerkungen_krone','bemerkungen_krone','regelkontrollen','r','text','','','1',NULL,'Textfeld','','Bemerkungen Krone','','17','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'bemerkungen_stamm','bemerkungen_stamm','regelkontrollen','r','text','','','1',NULL,'Textfeld','','Bemerkungen Stamm','','32','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'bemerkungen_stammfuss','bemerkungen_stammfuss','regelkontrollen','r','text','','','1',NULL,'Textfeld','','Bemerkungen Stammfuß','','41','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'bemerkungen_umfeld','bemerkungen_umfeld','regelkontrollen','r','text','','','1',NULL,'Textfeld','','Bemerkungen Umfeld','','52','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'bemerkungen_wurzel','bemerkungen_wurzel','regelkontrollen','r','text','','','1',NULL,'Textfeld','','Bemerkungen Wurzel','','45','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k1','k1','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Astab-/ausbrüche','','2','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k10','k10','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Pilzbefall','Pilzart bei Bemerkung eintragen!','11','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k11','k11','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Rindenschäden','','12','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k12','k12','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Totholzbildung','','13','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k13','k13','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Vergabelungen','','14','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k14','k14','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Wipfeldürre','','15','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k15','k15','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Zwiesel','','16','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k2','k2','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Astungswunden/-fäulen','','3','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k3','k3','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Baumfremder Bewuchs','','4','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k4','k4','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Belaubung (Auffälligkeiten)','','5','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k5','k5','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Fehlentwicklung','','6','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k6','k6','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Höhlungen','','7','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k7','k7','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Kappungsstellen','','8','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k8','k8','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Kronensicherungen','','9','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'k9','k9','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Krone - Lichtraumprofil','','10','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'kontrollid','kontrollid','regelkontrollen','r','int4','','','0','32','Text','','Kontroll-ID','','0','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s1','s1','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Anfahrschäden','','18','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s10','s10','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Schadinsekten','','27','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s11','s11','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Schrägstand','','28','0');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s12','s12','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Stammaustriebe','','29','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s13','s13','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Wuchsanomalien','','30','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s14','s14','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Zwiesel','','31','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s2','s2','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Astungswunden','','19','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s3','s3','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Baumfremder Bewuchs','','20','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s4','s4','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Fäulen','','21','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s5','s5','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Gewindestangen o.ä.','','22','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s6','s6','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Höhlungen','','23','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s7','s7','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Pilzbefall','Pilzart bei Bemerkung eintragen!','24','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s8','s8','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Rindenschäden','','25','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'s9','s9','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stamm - Risse','','26','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v1','v1','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Baugruben/-gräben','','46','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v2','v2','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Bodenauf-/-abtrag','','47','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v3','v3','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Bodenverdichtung','','48','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v4','v4','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Bodenversiegelung','','49','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v5','v5','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Freistellung','','50','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'v6','v6','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Umfeld - Grundwasserabsenkung/-stau','','51','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w1','w1','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Adventiv-/Würgewurzeln','','33','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w2','w2','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Höhlungen','','34','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w3','w3','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Pilzbefall','Pilzart bei Bemerkung eintragen!','35','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w4','w4','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Rindenschäden','','36','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w5','w5','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Risse','','37','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w6','w6','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Verbreiterung','','38','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w7','w7','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Stockaustriebe','','39','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'w8','w8','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Stammfuß - Wuchsanomalien','','40','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'wu1','wu1','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Wurzel - Bodenaufwölbungen','','42','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'wu2','wu2','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Wurzel - Risse','','43','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'wu3','wu3','regelkontrollen','r','int2','','','1','16','Auswahlfeld','select \'0\' as value, \'-\' as output UNION select \'1\' as value, \'ja\' as output','Wurzel - Pilzbefall','Pilzart bei Bemerkung eintragen!','44','1');
INSERT INTO layer_attributes (`layer_id`,`name`,`real_name`,`tablename`,`table_alias_name`,`type`,`geometrytype`,`constraints`,`nullable`,`length`,`form_element_type`,`options`,`alias`,`tooltip`,`order`,`privileg`) VALUES(@last_layer_id30,'zurueck','zurueck','','','text','','',NULL,NULL,'SubFormFK','28,kontrollid;no_new_window','zur Kontrolle','','1','0');
UPDATE layer_attributes SET options = REPLACE(options, '30', @last_layer_id30) WHERE layer_id IN(@last_layer_id30) AND form_element_type IN ('SubFormPK', 'SubFormFK', 'SubFormEmbeddedPK');