|
|
|
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
|
|
|
|
169^RPTA-Makros^<#macro rpta_column_layout_fuellen>\ |
|
|
|
|
96^RPTA-Makros^<#macro rpta_column_layout_fuellen>\ |
|
|
|
|
CREATE temp TABLE tmp_rpta_column\ |
|
|
|
|
(\ |
|
|
|
|
uniquename varchar(255) NOT NULL,\ |
|
|
|
@ -128,7 +128,9 @@ from rpta_column_layout\
@@ -128,7 +128,9 @@ from rpta_column_layout\
|
|
|
|
|
where resultset_id in (select tid\ |
|
|
|
|
FROM rpta_resultset\ |
|
|
|
|
where uniquename='${rpta_column_layout.rpta_resultset}')\ |
|
|
|
|
and uniquename in (select uniquename from tmp_rpta_column_layout)\ |
|
|
|
|
and resultset_id in (select tid\ |
|
|
|
|
FROM rpta_resultset\ |
|
|
|
|
where uniquename='${rpta_column_layout.rpta_resultset}')\ |
|
|
|
|
;\ |
|
|
|
|
--falls neu\ |
|
|
|
|
insert into rpta_column_layout\ |
|
|
|
@ -151,7 +153,8 @@ insert into rpta_column_layout\
@@ -151,7 +153,8 @@ insert into rpta_column_layout\
|
|
|
|
|
description,\ |
|
|
|
|
is_virtual\ |
|
|
|
|
FROM tmp_rpta_column_layout T\ |
|
|
|
|
where not exists (select uniquename from tmp_rpta_column_layout_target);\ |
|
|
|
|
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\ |
|
|
|
@ -265,10 +268,20 @@ drop TABLE tmp_rpta_column2layout;\
@@ -265,10 +268,20 @@ drop TABLE tmp_rpta_column2layout;\
|
|
|
|
|
</#macro>\ |
|
|
|
|
\ |
|
|
|
|
<#macro rpta_interpret_column_layout nonvirtualTableFilter>\ |
|
|
|
|
<#assign columnLayoutHasTreeColumn=0 />\ |
|
|
|
|
<#assign treeColumnSrcFieldname="" />\ |
|
|
|
|
<#assign treeColumnTargetFieldname="" />\ |
|
|
|
|
<#assign treeColumnMaskFieldname="" />\ |
|
|
|
|
select \ |
|
|
|
|
--zuerst die Basisdaten:\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.coltype=="physicalColumn">\ |
|
|
|
|
<#if column.coltype=="treeColumn">\ |
|
|
|
|
<#assign columnLayoutHasTreeColumn=1 />\ |
|
|
|
|
<#assign treeColumnSrcFieldname=column.srcfieldname />\ |
|
|
|
|
<#assign treeColumnTargetFieldname=column.targetfieldname />\ |
|
|
|
|
<#assign treeColumnMaskFieldname=column.colfunction />\ |
|
|
|
|
null::varchar(255) as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.coltype=="physicalColumn">\ |
|
|
|
|
${column.srcfieldname} as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.coltype=="logicalColumn">\ |
|
|
|
|
${column.colfunction} as ${column.targetfieldname},\ |
|
|
|
@ -347,7 +360,112 @@ drop TABLE tmp_rpta_column2layout;\
@@ -347,7 +360,112 @@ drop TABLE tmp_rpta_column2layout;\
|
|
|
|
|
from tmp_stud2\ |
|
|
|
|
where 1=1\ |
|
|
|
|
;\ |
|
|
|
|
\ |
|
|
|
|
<#if columnLayoutHasTreeColumn==1>\ |
|
|
|
|
--Sichtaufbau:\ |
|
|
|
|
--Zuerst leere Zieltabelle anlegen:\ |
|
|
|
|
select \ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
${column.targetfieldname},\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
null::integer as sortnr\ |
|
|
|
|
into temp tmp_stud3\ |
|
|
|
|
from tmp_stud2\ |
|
|
|
|
where 1=0;\ |
|
|
|
|
--maxEbene ermitteln:\ |
|
|
|
|
<#assign maxEbene=0 />\ |
|
|
|
|
<#foreach einElement in .vars[treeColumnMaskFieldname].elements>\ |
|
|
|
|
<#if einElement.level > maxEbene >\ |
|
|
|
|
<#assign maxEbene=einElement.level />\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
-- ##################################################\ |
|
|
|
|
-- ######## Start der Schleife ######################\ |
|
|
|
|
-- ##################################################\ |
|
|
|
|
<#assign sortnr=0>\ |
|
|
|
|
--Schleife, über Fächer im ausgewählten Baum, Reihenfolge genau wie im Baum\ |
|
|
|
|
--diese Kommentare werden schon im 1. Schritt von generateSql gelöscht\ |
|
|
|
|
--für Entwicklungszwecke kann man tricksen\ |
|
|
|
|
<@addcomment "SCHLEIFE"/>\ |
|
|
|
|
\ |
|
|
|
|
<#foreach einElement in .vars[treeColumnMaskFieldname].elements>\ |
|
|
|
|
<@addcomment "${einElement.name}"/>\ |
|
|
|
|
<#if einElement.level < maxEbene >\ |
|
|
|
|
--zuerst Summenzeile:\ |
|
|
|
|
<#assign sortnr=sortnr+1>\ |
|
|
|
|
insert into tmp_stud3(\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
${column.targetfieldname},\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
sortnr)\ |
|
|
|
|
select\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.targetfieldname=treeColumnTargetFieldname>\ |
|
|
|
|
'${einElement.name}',\ |
|
|
|
|
<#elseif column.targetfieldname="ebene">\ |
|
|
|
|
${einElement.level},\ |
|
|
|
|
<#elseif column.targetfieldname=treeColumnSrcFieldname>\ |
|
|
|
|
null::char(1),\ |
|
|
|
|
<#elseif column.is_aggregate==1 \ |
|
|
|
|
&& column.colfunction?has_content \ |
|
|
|
|
&& column.coltype=="processingColumn"> \ |
|
|
|
|
${column.colfunction} as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.is_aggregate==1 \ |
|
|
|
|
&& (column.coltype == "logicalColumn" || column.coltype == "lookupColumn" || column.coltype == "physicalColumn")> \ |
|
|
|
|
sum(${column.targetfieldname}) as ${column.targetfieldname},\ |
|
|
|
|
<#else>\ |
|
|
|
|
null::char(1),\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
(${einElement.level}*10000) + ${sortnr} as sortnr\ |
|
|
|
|
from tmp_stud2\ |
|
|
|
|
where ${treeColumnSrcFieldname} in ${einElement.subkeys}\ |
|
|
|
|
\ |
|
|
|
|
;\ |
|
|
|
|
</#if>\ |
|
|
|
|
--dann darunter die Werte:\ |
|
|
|
|
<#assign sortnr=sortnr+1>\ |
|
|
|
|
insert into tmp_stud3(\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
${column.targetfieldname},\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
sortnr)\ |
|
|
|
|
select\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.targetfieldname=treeColumnTargetFieldname>\ |
|
|
|
|
'${einElement.name}',\ |
|
|
|
|
<#elseif column.targetfieldname="ebene">\ |
|
|
|
|
<#if einElement.level < maxEbene >\ |
|
|
|
|
${einElement.level+ 1},\ |
|
|
|
|
<#else>\ |
|
|
|
|
${einElement.level},\ |
|
|
|
|
</#if>\ |
|
|
|
|
<#elseif column.targetfieldname=treeColumnSrcFieldname>\ |
|
|
|
|
null::char(1),\ |
|
|
|
|
<#elseif column.is_aggregate==1 \ |
|
|
|
|
&& column.colfunction?has_content \ |
|
|
|
|
&& column.coltype=="processingColumn"> \ |
|
|
|
|
${column.colfunction} as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.is_aggregate==1 \ |
|
|
|
|
&& (column.coltype == "logicalColumn" || column.coltype == "lookupColumn" || column.coltype == "physicalColumn")> \ |
|
|
|
|
sum(${column.targetfieldname}) as ${column.targetfieldname},\ |
|
|
|
|
<#else>\ |
|
|
|
|
${column.targetfieldname},\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
(${einElement.level}*10000) + ${sortnr} as sortnr\ |
|
|
|
|
from tmp_stud2\ |
|
|
|
|
where s_tid_stg in ${einElement.subkeys}\ |
|
|
|
|
group by ca12staat_str\ |
|
|
|
|
;\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
\ |
|
|
|
|
drop table tmp_stud2;\ |
|
|
|
|
select * into tmp_stud2\ |
|
|
|
|
from tmp_stud3;\ |
|
|
|
|
drop table tmp_stud3;\ |
|
|
|
|
--Ende Sicht\ |
|
|
|
|
</#if>\ |
|
|
|
|
\ |
|
|
|
|
<#assign number_of_visible_colums=0 />\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.is_visible!=0>\ |
|
|
|
@ -680,7 +798,8 @@ insert into rpta_column_layout\
@@ -680,7 +798,8 @@ insert into rpta_column_layout\
|
|
|
|
|
description,\ |
|
|
|
|
is_virtual\ |
|
|
|
|
FROM tmp_rpta_column_layout T\ |
|
|
|
|
where not exists (select uniquename from tmp_rpta_column_layout_target);\ |
|
|
|
|
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\ |
|
|
|
|