-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Export INTERLIS Scripts and sql to develop Export QGEP/QGEP#388
- Loading branch information
Showing
10 changed files
with
3,131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java -jar ili2pg.jar --createEnumTxtCol --schemaimport --importTid --sqlEnableNull --createEnumTabs --createFk --noSmartMapping --dbdatabase qgep --dbschema vsa_dss_2015_2_d --dbusr postgres --dbpwd yourpassword --log createschema_VSA_DSS_2015_2_d.log VSA_DSS_2015_2_d.ili |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- this file generates a new SQL function to create TIDs for all the tables of the import/export schema with ili2pg. | ||
-- you need to set the current maxvalue of the TID into the schema.table.field vsa_dss_2015_2_d.t_key_object.t_lastuniqueid | ||
-- questions regarding this function should be directed to Stefan Burckhardt [email protected] | ||
-- basis ist tid_generate.sql | ||
-- schema für export heisst vsa_dss_2015_2_304 | ||
|
||
|
||
-- function for generating TIDs | ||
CREATE OR REPLACE FUNCTION vsa_dss_2015_2_d.tid_generate(table_name text, obj_id_table text) | ||
-- RETURNS text AS | ||
RETURNS integer AS | ||
$BODY$ | ||
DECLARE | ||
nexttid integer; | ||
newtid integer; | ||
-- myrec_prefix record; | ||
-- myrec_shortcut record; | ||
-- myrec_seq record; | ||
BEGIN | ||
--get sequence for table | ||
-- SELECT nextval('qgep.seq_' || table_name || '_oid') AS seqval INTO myrec_seq; | ||
-- SELECT nextval('vsa_dss_2015_2_d.seq_' || table_name || '_tid') AS seqval INTO myrec_seq; | ||
-- 23.12.2015 SELECT t_lastuniqueid FROM vsa_dss_2015_2_d.t_key_object AS nexttid; | ||
SELECT t_lastuniqueid INTO nexttid FROM vsa_dss_2015_2_d.t_key_object; | ||
newtid = (nexttid + 1); | ||
|
||
-- 12.1.2016 | ||
RAISE NOTICE 'newtid is %', newtid; -- Print newtid | ||
RAISE NOTICE 'nexttid is %', nexttid; -- Print nexttid | ||
|
||
-- adapt t_lastuniqueid in t_key_object | ||
UPDATE vsa_dss_2015_2_d.t_key_object | ||
SET t_lastuniqueid = newtid | ||
, t_user = current_user | ||
, t_createdate = current_timestamp | ||
WHERE t_lastuniqueid = nexttid; | ||
|
||
IF NOT FOUND THEN | ||
RAISE EXCEPTION 'sequence for table % not found', table_name; | ||
ELSE | ||
RAISE NOTICE 't_key_object updated'; | ||
END IF; | ||
-- RETURN myrec_prefix.prefix || myrec_shortcut.shortcut_en || to_char(myrec_seq.seqval,'FM000000'); | ||
-- RETURN myrec_prefix.prefix || to_char(myrec_seq.seqval,'FM000000'); | ||
RETURN newtid; | ||
|
||
|
||
|
||
END; | ||
$BODY$ | ||
-- 12.1.2016 geändert LANGUAGE plpgsql STABLE | ||
LANGUAGE plpgsql VOLATILE | ||
COST 100; | ||
|
16 changes: 16 additions & 0 deletions
16
sql/export/interlis/021_vsa_dss_2015_2_d_create_seq_ili2db.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- neu 22.11.2016 fehlt mit --createscript in schema | ||
|
||
-- Schema: vsa_dss_2015_2_d. | ||
|
||
-- DROP SCHEMA vsa_dss_2015_2_304 CASCADE; | ||
|
||
CREATE SEQUENCE vsa_dss_2015_2_d.t_ili2db_seq | ||
increment 1 | ||
minValue 1 | ||
maxValue 9223372036854775807 | ||
start 1 | ||
cache 1; | ||
|
||
|
||
ALTER TABLE vsa_dss_2015_2_d.t_ili2db_seq | ||
OWNER TO postgres; |
51 changes: 51 additions & 0 deletions
51
sql/export/interlis/022_vsa_dss_2015_2_d_basket_update.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- neu 26.11.2016 Stefan Burckhardt / 4.7.2017 corrected | ||
-- Updates data in vsa_dss_2015_2_d.t_ili2db_import_basket with last tid from t_key_object | ||
|
||
-- Function: vsa_dss_2015_2_d.basket_update() | ||
|
||
-- DROP FUNCTION vsa_dss_2015_2_d.basket_update(); | ||
|
||
CREATE OR REPLACE FUNCTION vsa_dss_2015_2_d.basket_update() | ||
RETURNS integer AS | ||
$BODY$ | ||
DECLARE | ||
lasttid integer; | ||
BEGIN | ||
--get sequence for table | ||
-- SELECT nextval('qgep.seq_' || table_name || '_oid') AS seqval INTO myrec_seq; | ||
-- SELECT nextval('sia405_abwasser_2015_2_d_301.seq_' || table_name || '_tid') AS seqval INTO myrec_seq; | ||
|
||
SELECT t_lastuniqueid INTO lasttid FROM vsa_dss_2015_2_d.t_key_object; | ||
|
||
|
||
-- 25.11.2016 | ||
RAISE NOTICE '[basket_update]: lasttid is %', lasttid; -- Print lasttid | ||
|
||
|
||
-- adapt t_lastuniqueid in t_key_object | ||
UPDATE vsa_dss_2015_2_d.t_ili2db_import_basket | ||
SET t_id = lasttid + 1 | ||
, end_t_id = lasttid | ||
, objectcount = lasttid - 2 | ||
WHERE import = 2; | ||
|
||
IF NOT FOUND THEN | ||
RAISE EXCEPTION 'sequence for table basket_update not found - first data will be inserte'; | ||
INSERT INTO vsa_dss_2015_d_391.t_ili2db_import_basket (t_id, import, basket, objectcount, start_t_id, end_t_id) VALUES (lasttid + 1, 2, 3, lasttid - 2, 3, lasttid); | ||
|
||
ELSE | ||
RAISE NOTICE 't_ili2db_import_basket updated %', lasttid; | ||
-- SELECT setval (sia405_abwasser_2015_2_d_340.t_ili2db_seq, lasttid + 1); | ||
END IF; | ||
-- RETURN myrec_prefix.prefix || myrec_shortcut.shortcut_en || to_char(myrec_seq.seqval,'FM000000'); | ||
-- RETURN myrec_prefix.prefix || to_char(myrec_seq.seqval,'FM000000'); | ||
RETURN lasttid; | ||
|
||
|
||
|
||
END; | ||
$BODY$ | ||
LANGUAGE plpgsql VOLATILE | ||
COST 100; | ||
ALTER FUNCTION vsa_dss_2015_2_d.basket_update() | ||
OWNER TO postgres; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- this file looks up the t_id for foreignkeys (OID) for the tables of the import/export schema with ili2pg. | ||
-- questions regarding this function should be directed to Stefan Burckhardt [email protected] | ||
-- basis ist tid_lookup.sql | ||
-- schema für export heisst vsa_dss_2015_2_d. | ||
-- last update 18.11.2016 Stefan Burckhardt | ||
|
||
-- function for looking up t_id | ||
CREATE OR REPLACE FUNCTION vsa_dss_2015_2_d.tid_lookup(table_name text, obj_id_ref text) | ||
-- RETURNS text AS | ||
RETURNS integer AS | ||
$BODY$ | ||
DECLARE | ||
tid_ref integer; | ||
-- newtid integer; | ||
-- myrec_prefix record; | ||
-- myrec_shortcut record; | ||
-- myrec_seq record; | ||
BEGIN | ||
-- 9.3.2016 check whether obj_id_ref NOT IS NULL | ||
IF obj_id_ref IS NULL THEN | ||
tid_ref = NULL; | ||
RAISE NOTICE '[tid_lookup]: obj_id is NULL . tid_ref set NULL also'; -- Print newtid | ||
ELSE | ||
-- get tid_ref for foreignkey | ||
-- SELECT t_id INTO tid_ref FROM vsa_dss_2015_2_d.baseclass WHERE t_ili_tid = 'ch13p7mzOG000002'; | ||
SELECT t_id INTO tid_ref FROM vsa_dss_2015_2_d.baseclass WHERE t_ili_tid = obj_id_ref; | ||
|
||
IF NOT FOUND THEN | ||
-- 13.2.2016 / 9.3.2016 improved error message | ||
-- RAISE EXCEPTION 'tid_ref for table % not found', table_name; | ||
RAISE NOTICE '[tid_lookup]: Corresponding to obj_id % ->',obj_id_ref; -- Print newtid | ||
RAISE NOTICE 'tid_ref for table % not found', table_name; | ||
RAISE EXCEPTION 'Missing t_id in table baseclass'; | ||
|
||
ELSE | ||
-- 12.1.2016 | ||
-- 13.2.2016 comment out to speed up | ||
-- 9.3.2016 Hineis ergänzt mit OBJ_ID | ||
RAISE NOTICE '[tid_lookup]: Corresponding to obj_id % ->',obj_id_ref; -- Print newtid | ||
RAISE NOTICE 'tid_ref is %', tid_ref; | ||
|
||
END IF; | ||
END IF; | ||
|
||
RETURN tid_ref; | ||
|
||
END; | ||
$BODY$ | ||
-- 12.1.2016 geändert LANGUAGE plpgsql STABLE | ||
LANGUAGE plpgsql VOLATILE | ||
COST 100; | ||
|
25 changes: 25 additions & 0 deletions
25
sql/export/interlis/046_vsa_dss_2015_2_d_t_key_object_insert_metadata.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- 24.11.2016 auch create statement nötig, Tabelle fehlt in --createscript (an Eisenhut gemeldet) | ||
-- Stefan Burckhardt | ||
|
||
-- Table: vsadss2015_2_d_391.t_key_object | ||
|
||
-- DROP TABLE vsadss2015_2_d_391.t_key_object; | ||
|
||
CREATE TABLE vsa_dss_2015_2_d.t_key_object | ||
( | ||
t_key character varying(30) NOT NULL, | ||
t_lastuniqueid integer NOT NULL, | ||
t_lastchange timestamp without time zone NOT NULL, | ||
t_createdate timestamp without time zone NOT NULL, | ||
t_user character varying(40) NOT NULL, | ||
CONSTRAINT t_key_object_pkey PRIMARY KEY (t_key) | ||
) | ||
WITH ( | ||
OIDS=FALSE | ||
); | ||
ALTER TABLE vsa_dss_2015_2_d.t_key_object | ||
OWNER TO postgres; | ||
|
||
-- erster Eintrag in t_key_object | ||
|
||
INSERT INTO vsa_dss_2015_2_d.t_key_object (t_key, t_lastuniqueid, t_lastchange, t_createdate, t_user) VALUES ( 't_id', 0, current_timestamp, current_timestamp, 'postgres'); |
Oops, something went wrong.