Daniel Quathamer
2 years ago
6 changed files with 185 additions and 36 deletions
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
--freemarker template |
||||
<#if SQLdialect='Postgres'> |
||||
select setval('sichten_tid_seq',(select max(tid) from sichten)); |
||||
</#if> |
||||
<#assign systeminfoid="1000" /> |
||||
<#assign sichten = [ |
||||
{"name_intern":"xcube_dim_alter", |
||||
"name":"Alter (gruppiert in 5er-Schritten)", |
||||
"quelle":"<<SQL>> select name,apnr,parent,strukturstr from xcube_dims where id=''alter'' order by 2", |
||||
"art":"XCUBE-Alter-Sicht"}, |
||||
{"name_intern":"xcube_dim_wohnort", |
||||
"name":"Wohnort nach Bundesländern", |
||||
"quelle":"<<SQL>> select ''Deutschland''::varchar(255) as druck , ''0'' as apnr, null::varchar(255) as parent from xdummy union select druck,apnr,''0'' from cifx where key=8 union select druck, '''' || val(astat), bund_apnr from cifx where key=11 order by 1", |
||||
"art":"XCUBE-Wohnort-Sicht"} |
||||
|
||||
] /> |
||||
|
||||
|
||||
--Ab hier braucht man nichts ändern: |
||||
|
||||
CREATE temp TABLE tmp_sichten ( |
||||
parent character(255), |
||||
systeminfoid integer DEFAULT 0 NOT NULL, |
||||
art character(40), |
||||
type integer , |
||||
name_intern character(200), |
||||
name character(200), |
||||
beschreibung character(255), |
||||
sortnr integer DEFAULT 0 NOT NULL, |
||||
quelle character(255), |
||||
alt_hier_id character(150), |
||||
treecfgtable character(255), |
||||
treecfgid character(150), |
||||
label smallint DEFAULT 0 NOT NULL, |
||||
user_rechte smallint DEFAULT 1 NOT NULL, |
||||
rechtequelle character(255), |
||||
sesamkey character(100), |
||||
standbutton smallint DEFAULT 0 NOT NULL, |
||||
attribut1 character(255), |
||||
attribut2 character(255), |
||||
attribut3 integer, |
||||
attribut4 integer, |
||||
xmlmaxentries integer, |
||||
gueltig_seit date , |
||||
gueltig_bis date, |
||||
aktiv smallint DEFAULT 1 |
||||
); |
||||
<#assign sortnr=0 /> |
||||
<#foreach sicht in sichten> |
||||
<#assign sortnr=sortnr+1 /> |
||||
-- Sicht ${sicht.name} |
||||
|
||||
INSERT INTO tmp_sichten( |
||||
systeminfoid , |
||||
art , |
||||
type , |
||||
name_intern , |
||||
name , |
||||
sortnr , |
||||
quelle , |
||||
label , |
||||
user_rechte , |
||||
standbutton , |
||||
gueltig_seit , |
||||
gueltig_bis , |
||||
aktiv |
||||
) select |
||||
${systeminfoid} , |
||||
'${sicht.art}' , |
||||
10 , |
||||
'${sicht.name_intern}' , |
||||
'${sicht.name}' , |
||||
${sortnr} , |
||||
'${sicht.quelle}', |
||||
0 , |
||||
0 , |
||||
0 , |
||||
date_val('01.01.1900') , |
||||
date_val('01.01.3000') , |
||||
1 from xdummy; |
||||
</#foreach> |
||||
|
||||
--Zur Sicherheit alle Quellen und Standbutton von Sichten |
||||
update sichten set quelle=(select T.quelle from tmp_sichten T |
||||
where T.name_intern=sichten.name_intern) |
||||
where name_intern in (select T2.name_intern from tmp_sichten T2) |
||||
; |
||||
update sichten set standbutton=(select T.standbutton from tmp_sichten T |
||||
where T.name_intern=sichten.name_intern) |
||||
where name_intern in (select T2.name_intern from tmp_sichten T2) |
||||
; |
||||
|
||||
delete from tmp_sichten where name_intern in (select name_intern from sichten); |
||||
|
||||
|
||||
INSERT INTO sichten( |
||||
systeminfoid , art , type , name_intern , name , |
||||
sortnr , quelle , label , |
||||
user_rechte , standbutton , |
||||
xmlmaxentries , |
||||
gueltig_seit , gueltig_bis , aktiv) |
||||
select systeminfoid , art , type , name_intern , name , |
||||
sortnr , quelle , label , |
||||
user_rechte , standbutton , |
||||
xmlmaxentries , |
||||
gueltig_seit , gueltig_bis , aktiv |
||||
from tmp_sichten S; |
||||
|
||||
|
||||
--Rechte für Sichten geben |
||||
select 'Rechte für Sichten geben' from xdummy; |
||||
delete from sachgeb_sichtarten where sichtart in |
||||
(select distinct art from tmp_sichten); |
||||
|
||||
insert into sachgeb_sichtarten |
||||
( |
||||
sachgebiete_id , |
||||
sichtart |
||||
) |
||||
select distinct ${systeminfoid},art from tmp_sichten; |
||||
|
||||
|
||||
drop table tmp_sichten; |
||||
|
@ -1,4 +0,0 @@
@@ -1,4 +0,0 @@
|
||||
--SQL-Sicht für die Dimension Alter |
||||
delete from sichten where art='xcube_dim_alter'; |
||||
insert into sichten (art,type,name_intern,name,quelle,gueltig_seit,gueltig_bis,aktiv) |
||||
values ('xcube_dim_alter',10,'xdim_alter','Alter','<<SQL>> select name,apnr,parent,strukturstr from xcube_dims where id=''alter''','1900-01-01','3000-01-01',1); |
Loading…
Reference in new issue