11 changed files with 426 additions and 18 deletions
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
--freemarker template |
||||
<#include "RPTA-Makros"/> |
||||
<sqlvars> |
||||
<sqlvar name="sos_stud_astat_exists"> |
||||
select count(*) from rpta_resultset where uniquename='sos_stud_astat'; |
||||
</sqlvar> |
||||
</sqlvars> |
||||
<#assign rpta_column_layout = {"uniquename":"sos_stud_astat_hssem_1_repo", |
||||
"caption":"Studierende / 1. HS", |
||||
"rpta_resultset":"sos_stud_astat", |
||||
"whereclause":"${SOS_HH_NH_ZH}", |
||||
"description":"Haupt- und Nebenhörer_innen" |
||||
} |
||||
/> |
||||
|
||||
<#assign rpta_columns = [ |
||||
{"uniquename":"dim_studiengang_stg_str", |
||||
"caption_der_spalte":"Studienfach", |
||||
"caption_in_ergebnistabelle":"Studienfach", |
||||
"srcfieldname":"dim_studiengang_stg_str", |
||||
"column_type":"physicalColumn", |
||||
"col_function":"", |
||||
"is_visible":"1", |
||||
"visible_size":"10", |
||||
"is_aggregate":"0", |
||||
"description":"" |
||||
}, |
||||
{"uniquename":"sos_stud_astat_hssem1", |
||||
"caption_der_spalte":"Summe erstes Hochschulsemester", |
||||
"caption_in_ergebnistabelle":"Summe erstes Hochschulsemester", |
||||
"srcfieldname":"", |
||||
"targetfieldname":"sos_stud_astat_hssem1", |
||||
"column_type":"logicalColumn", |
||||
"col_function":"case when ${SOS_HSSEM_1} then summe else 0 end", |
||||
"is_visible":"1", |
||||
"visible_size":"10", |
||||
"is_aggregate":"1", |
||||
"description":"" |
||||
}, |
||||
{"uniquename":"summe", |
||||
"caption_der_spalte":"Summe der Studierenden", |
||||
"caption_in_ergebnistabelle":"Summe der Studierenden", |
||||
"srcfieldname":"summe", |
||||
"column_type":"physicalColumn", |
||||
"col_function":"sum", |
||||
"is_visible":"1", |
||||
"visible_size":"5", |
||||
"is_aggregate":"1", |
||||
"description_der_spalte":"Summe der Studierenden", |
||||
"description_in_ergebnistabelle":"Summe der Studierenden" |
||||
|
||||
} |
||||
] |
||||
/> |
||||
|
||||
|
||||
|
||||
<@rpta_column_layout_fuellen /> |
||||
@ -0,0 +1,313 @@
@@ -0,0 +1,313 @@
|
||||
--automatically created by SuperX/Freemarker for Postgres (27.04.2026 07:38:19) |
||||
|
||||
|
||||
|
||||
|
||||
CREATE temp TABLE tmp_rpta_column |
||||
( |
||||
uniquename varchar(255) NOT NULL, |
||||
caption varchar(255), |
||||
caption_in_ergebnistabelle varchar(255), |
||||
srcfieldname varchar(255), |
||||
targetfieldname varchar(255), |
||||
column_type integer, |
||||
col_function text, |
||||
is_visible smallint, |
||||
visible_size smallint, |
||||
is_aggregate smallint, |
||||
resultset_id integer, |
||||
sortnr integer, |
||||
description TEXT, |
||||
description_in_ergebnistabelle TEXT, |
||||
format_code_uniquename varchar(255), |
||||
format_code_id integer |
||||
); |
||||
|
||||
CREATE temp TABLE tmp_rpta_column_layout |
||||
( |
||||
uniquename varchar(255) NOT NULL, |
||||
caption varchar(255), |
||||
resultset_id integer, |
||||
whereclause text, |
||||
sortclause text, |
||||
description text, |
||||
is_virtual smallint default 1 |
||||
); |
||||
|
||||
insert into tmp_rpta_column_layout( |
||||
resultset_id, |
||||
uniquename, |
||||
caption, |
||||
whereclause, |
||||
description |
||||
) |
||||
select tid, |
||||
'sos_stud_astat_hssem_1_repo', |
||||
'Studierende / 1. HS', |
||||
'${SOS_HH_NH_ZH}', |
||||
'Haupt- und Nebenhörer_innen' |
||||
FROM rpta_resultset |
||||
where uniquename='sos_stud_astat'; |
||||
|
||||
|
||||
INSERT INTO tmp_rpta_column |
||||
(resultset_id, |
||||
uniquename, |
||||
caption, |
||||
caption_in_ergebnistabelle, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_visible, |
||||
visible_size, |
||||
is_aggregate, |
||||
sortnr, |
||||
description, |
||||
description_in_ergebnistabelle, |
||||
format_code_uniquename |
||||
) |
||||
select R.tid, |
||||
'dim_studiengang_stg_str', |
||||
'Studienfach', |
||||
'Studienfach', |
||||
'dim_studiengang_stg_str', |
||||
'dim_studiengang_stg_str' , |
||||
T.tid as column_type, |
||||
'', |
||||
1, |
||||
10, |
||||
0, |
||||
10, |
||||
'', |
||||
'', |
||||
null::varchar |
||||
FROM rpta_resultset R, rpta_column_type T |
||||
where R.uniquename='sos_stud_astat' |
||||
and T.uniquename='physicalColumn'; |
||||
|
||||
|
||||
INSERT INTO tmp_rpta_column |
||||
(resultset_id, |
||||
uniquename, |
||||
caption, |
||||
caption_in_ergebnistabelle, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_visible, |
||||
visible_size, |
||||
is_aggregate, |
||||
sortnr, |
||||
description, |
||||
description_in_ergebnistabelle, |
||||
format_code_uniquename |
||||
) |
||||
select R.tid, |
||||
'sos_stud_astat_hssem1', |
||||
'Summe erstes Hochschulsemester', |
||||
'Summe erstes Hochschulsemester', |
||||
'', |
||||
'sos_stud_astat_hssem1' , |
||||
T.tid as column_type, |
||||
'case when ${SOS_HSSEM_1} then summe else 0 end', |
||||
1, |
||||
10, |
||||
1, |
||||
20, |
||||
'', |
||||
'', |
||||
null::varchar |
||||
FROM rpta_resultset R, rpta_column_type T |
||||
where R.uniquename='sos_stud_astat' |
||||
and T.uniquename='logicalColumn'; |
||||
|
||||
|
||||
INSERT INTO tmp_rpta_column |
||||
(resultset_id, |
||||
uniquename, |
||||
caption, |
||||
caption_in_ergebnistabelle, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_visible, |
||||
visible_size, |
||||
is_aggregate, |
||||
sortnr, |
||||
description, |
||||
description_in_ergebnistabelle, |
||||
format_code_uniquename |
||||
) |
||||
select R.tid, |
||||
'summe', |
||||
'Summe der Studierenden', |
||||
'Summe der Studierenden', |
||||
'summe', |
||||
'summe' , |
||||
T.tid as column_type, |
||||
'sum', |
||||
1, |
||||
5, |
||||
1, |
||||
30, |
||||
'Summe der Studierenden', |
||||
'Summe der Studierenden', |
||||
null::varchar |
||||
FROM rpta_resultset R, rpta_column_type T |
||||
where R.uniquename='sos_stud_astat' |
||||
and T.uniquename='physicalColumn'; |
||||
|
||||
|
||||
update tmp_rpta_column set format_code_id=C.tid |
||||
from rpta_format_code C |
||||
where C.uniquename=tmp_rpta_column.format_code_uniquename |
||||
and format_code_uniquename is not null; |
||||
|
||||
|
||||
select * into temp tmp_rpta_column2layout |
||||
from rpta_column2layout |
||||
where layout_id in (select L.tid |
||||
from rpta_column_layout L,rpta_resultset R |
||||
where R.tid=L.resultset_id |
||||
and R.uniquename='sos_stud_astat' |
||||
and L.uniquename='sos_stud_astat_hssem_1_repo' |
||||
) |
||||
; |
||||
|
||||
select uniquename into temp tmp_rpta_column_layout_target |
||||
from rpta_column_layout |
||||
where resultset_id in (select tid |
||||
FROM rpta_resultset |
||||
where uniquename='sos_stud_astat') |
||||
and resultset_id in (select tid |
||||
FROM rpta_resultset |
||||
where uniquename='sos_stud_astat') |
||||
; |
||||
--falls neu |
||||
insert into rpta_column_layout |
||||
(uniquename, |
||||
caption, |
||||
resultset_id, |
||||
whereclause, |
||||
sortclause, |
||||
description, |
||||
is_virtual) |
||||
select uniquename, |
||||
caption, |
||||
resultset_id, |
||||
whereclause, |
||||
null::text as sortclause, |
||||
description, |
||||
is_virtual |
||||
FROM tmp_rpta_column_layout T |
||||
where not exists (select T2.uniquename from tmp_rpta_column_layout_target T2 |
||||
where T2.uniquename=T.uniquename); |
||||
|
||||
--falls geändert, uniquename muss bleiben |
||||
update rpta_column_layout |
||||
set (caption, resultset_id, whereclause,sortclause, description, is_virtual) |
||||
= ( select caption, resultset_id, |
||||
whereclause, |
||||
null::text as sortclause, |
||||
description, |
||||
is_virtual |
||||
FROM tmp_rpta_column_layout T |
||||
where T.uniquename=rpta_column_layout.uniquename) |
||||
where rpta_column_layout.uniquename=(select uniquename from tmp_rpta_column_layout); |
||||
|
||||
drop table tmp_rpta_column_layout_target; |
||||
|
||||
delete from rpta_column2layout |
||||
where layout_id in (select L.tid |
||||
from rpta_column_layout L,rpta_resultset R |
||||
where R.tid=L.resultset_id |
||||
and R.uniquename='sos_stud_astat' |
||||
and L.uniquename='sos_stud_astat_hssem_1_repo' |
||||
) |
||||
; |
||||
|
||||
select * into temp tmp_rpta_column2 |
||||
from tmp_rpta_column T |
||||
where (resultset_id,uniquename) not in |
||||
(select resultset_id,uniquename from rpta_column); |
||||
|
||||
INSERT INTO rpta_column |
||||
(resultset_id, |
||||
uniquename, |
||||
caption, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_aggregate, |
||||
description, |
||||
custom |
||||
) |
||||
select |
||||
resultset_id, |
||||
uniquename, |
||||
caption, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_aggregate, |
||||
description, |
||||
0 as custom |
||||
from tmp_rpta_column2; |
||||
|
||||
--evtl. neuen Satz einfügen, dann alle updaten |
||||
|
||||
update rpta_column set ( caption, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_aggregate, |
||||
description) |
||||
= (select caption, |
||||
srcfieldname, |
||||
targetfieldname, |
||||
column_type, |
||||
col_function, |
||||
is_aggregate, |
||||
description |
||||
from tmp_rpta_column T |
||||
where T.resultset_id=rpta_column.resultset_id |
||||
and T.uniquename=rpta_column.uniquename) |
||||
where custom=0 |
||||
and (resultset_id,uniquename) in |
||||
(select T.resultset_id,T.uniquename |
||||
from tmp_rpta_column T) |
||||
; |
||||
|
||||
drop table tmp_rpta_column2; |
||||
|
||||
insert into rpta_column2layout(column_id, |
||||
layout_id, |
||||
sortnr, |
||||
is_visible, |
||||
visible_size, |
||||
caption, |
||||
description, |
||||
format_code_id) |
||||
select C.tid as column_id, |
||||
L.tid as layout_id, |
||||
T.sortnr, |
||||
T.is_visible, |
||||
T.visible_size, |
||||
T.caption_in_ergebnistabelle, |
||||
T.description_in_ergebnistabelle, |
||||
T.format_code_id |
||||
FROM rpta_column C, rpta_column_layout L, tmp_rpta_column T |
||||
where C.uniquename=T.uniquename |
||||
and C.resultset_id=T.resultset_id |
||||
and L.uniquename='sos_stud_astat_hssem_1_repo' |
||||
and L.resultset_id=T.resultset_id |
||||
; |
||||
drop table tmp_rpta_column; |
||||
drop TABLE tmp_rpta_column_layout; |
||||
drop TABLE tmp_rpta_column2layout; |
||||
Loading…
Reference in new issue