|
|
|
@ -0,0 +1,214 @@
@@ -0,0 +1,214 @@
|
|
|
|
|
48110^Leistungen und Studiengänge^--Freemarker Template\ |
|
|
|
|
<#include "SQL_lingua_franca"/>\ |
|
|
|
|
<#include "SuperX_general"/>\ |
|
|
|
|
--\ |
|
|
|
|
--Autor D. Quathamer 2024\ |
|
|
|
|
<sqlvars>\ |
|
|
|
|
<sqlvar name="basetable" type="hash"><![CDATA[\ |
|
|
|
|
<#assign my_base_rs='lm_exam_unit_dim_studiengang' />\ |
|
|
|
|
SELECT distinct name,\ |
|
|
|
|
0::smallint as is_virtual,\ |
|
|
|
|
name as runtime_tablename\ |
|
|
|
|
from sx_tables\ |
|
|
|
|
where name in ('${my_base_rs}')\ |
|
|
|
|
and 0=(select count(*) from rpta_resultset R where R.uniquename='${my_base_rs}')\ |
|
|
|
|
union\ |
|
|
|
|
select R.uniquename,\ |
|
|
|
|
1::smallint as is_virtual,\ |
|
|
|
|
'tmp_' || R.uniquename as runtime_tablename\ |
|
|
|
|
from rpta_resultset R where R.uniquename='${my_base_rs}'\ |
|
|
|
|
;\ |
|
|
|
|
]]>\ |
|
|
|
|
</sqlvar>\ |
|
|
|
|
<sqlvar name="rpta_resultset" type="hash"><![CDATA[\ |
|
|
|
|
select caption,\ |
|
|
|
|
uniquename,\ |
|
|
|
|
fieldclause,\ |
|
|
|
|
joinclause,\ |
|
|
|
|
whereclause,\ |
|
|
|
|
systeminfo_id\ |
|
|
|
|
from rpta_resultset\ |
|
|
|
|
where uniquename='${basetable.name}';\ |
|
|
|
|
\ |
|
|
|
|
]]></sqlvar>\ |
|
|
|
|
<sqlvar name="rpta_column_layout" type="hash"><![CDATA[\ |
|
|
|
|
select L.uniquename,\ |
|
|
|
|
L.caption,\ |
|
|
|
|
L.whereclause\ |
|
|
|
|
from rpta_resultset R, rpta_column_layout L\ |
|
|
|
|
where L.resultset_id=R.tid\ |
|
|
|
|
and R.uniquename='${basetable.name}'\ |
|
|
|
|
and L.uniquename=<<Spaltenlayout>>;\ |
|
|
|
|
\ |
|
|
|
|
]]></sqlvar>\ |
|
|
|
|
<sqlvar name="columns" type="hashsequence"><![CDATA[\ |
|
|
|
|
SELECT C.srcfieldname,\ |
|
|
|
|
(case when string_not_null(C.targetfieldname)='' then C.srcfieldname else C.targetfieldname end) as targetfieldname,\ |
|
|
|
|
T.uniquename as coltype,\ |
|
|
|
|
C.is_aggregate,\ |
|
|
|
|
(case when string_not_null(CL.caption)='' then C.caption else CL.caption end) as caption,\ |
|
|
|
|
CL.is_visible,\ |
|
|
|
|
CL.visible_size as visible_width,\ |
|
|
|
|
(select F.sql_code from rpta_format_code F where F.tid=CL.format_code_id) as format_sql,\ |
|
|
|
|
C.col_function as colfunction,\ |
|
|
|
|
(case when string_not_null(CL.description)='' then C.description else CL.description end) as description\ |
|
|
|
|
FROM rpta_column_layout L, rpta_column2layout CL, rpta_column C, rpta_column_type T\ |
|
|
|
|
where L.tid=CL.layout_id\ |
|
|
|
|
and C.tid=CL.column_id\ |
|
|
|
|
and T.tid=C.column_type\ |
|
|
|
|
and L.uniquename=<<Spaltenlayout>>\ |
|
|
|
|
/* and C.uniquename in (<<Spalten>>) */\ |
|
|
|
|
order by CL.sortnr\ |
|
|
|
|
;\ |
|
|
|
|
]]></sqlvar>\ |
|
|
|
|
</sqlvars>\ |
|
|
|
|
\ |
|
|
|
|
<#assign filter="1=1\ |
|
|
|
|
/* and sem_der_pruefung >= <<Seit Semester>> */\ |
|
|
|
|
/* and sem_der_pruefung <= <<Bis Semester>> */\ |
|
|
|
|
/* and sem_der_pruefung = <<Semester>> */\ |
|
|
|
|
/* and substring('' || sem_der_pruefung from 5 for 1)='<<Semestertyp>>' */\ |
|
|
|
|
" />\ |
|
|
|
|
\ |
|
|
|
|
<#assign filter = filter + " and 's_' || tid_stg in "+Studiengang.allNeededKeysList /> \ |
|
|
|
|
\ |
|
|
|
|
<#if columns?has_content>\ |
|
|
|
|
\ |
|
|
|
|
<#if basetable.is_virtual==1>\ |
|
|
|
|
\ |
|
|
|
|
create temp table ${basetable.runtime_tablename} as\ |
|
|
|
|
select ${rpta_resultset.fieldclause} \ |
|
|
|
|
from ${rpta_resultset.joinclause} \ |
|
|
|
|
where 1=1\ |
|
|
|
|
<#if rpta_resultset.whereclause != ""> \ |
|
|
|
|
${rpta_resultset.whereclause} </#if>\ |
|
|
|
|
and ${filter}\ |
|
|
|
|
;\ |
|
|
|
|
</#if>\ |
|
|
|
|
\ |
|
|
|
|
\ |
|
|
|
|
\ |
|
|
|
|
select \ |
|
|
|
|
--zuerst die Basisdaten:\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.coltype="physicalColumn">\ |
|
|
|
|
${column.srcfieldname} as ${column.srcfieldname},\ |
|
|
|
|
<#elseif column.coltype="logicalColumn">\ |
|
|
|
|
${column.colfunction} as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.coltype="lookupColumn">\ |
|
|
|
|
(${column.colfunction}) as ${column.targetfieldname},\ |
|
|
|
|
<#elseif column.coltype="computedColumn" || column.coltype=="processingColumn">\ |
|
|
|
|
null::decimal(19,6) as ${column.targetfieldname},\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
null::char(1) as dummycol\ |
|
|
|
|
into temp tmp_stud\ |
|
|
|
|
from ${basetable.runtime_tablename}\ |
|
|
|
|
<#if rpta_column_layout.whereclause !="">\ |
|
|
|
|
where ${rpta_column_layout.whereclause}\ |
|
|
|
|
</#if>\ |
|
|
|
|
;\ |
|
|
|
|
\ |
|
|
|
|
--ergebnistabelle:\ |
|
|
|
|
select \ |
|
|
|
|
--zuerst die nicht-Aggregate:\ |
|
|
|
|
<#assign groupby=0 />\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
-- logicalColumns ausgeschlossen, da sie von processingColumns aggregiert werden\ |
|
|
|
|
-- computedColumns immer mitnehmen, da später verarbeitet\ |
|
|
|
|
<#if column.is_aggregate==0 && column.coltype!="logicalColumn" && column.coltype!="processingColumn" || column.coltype="computedColumn"> \ |
|
|
|
|
<#assign groupby=groupby+1 />\ |
|
|
|
|
${column.targetfieldname},\ |
|
|
|
|
<#elseif column.is_aggregate==0 && column.coltype="processingColumn"> \ |
|
|
|
|
<#assign groupby=groupby+1 />\ |
|
|
|
|
${column.srcfieldname} as ${column.targetfieldname},\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
--dann die Aggregate:\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
-- logicalColumns ausgeschlossen, da sie von processingColumns aggregiert werden\ |
|
|
|
|
-- computedColumns ausgeschlossen, da später im finalen select verarbeitet\ |
|
|
|
|
<#if column.is_aggregate==1 && column.coltype!="computedColumn" && column.coltype!="logicalColumn"> \ |
|
|
|
|
${column.colfunction}(${column.srcfieldname}) as ${column.targetfieldname},\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
null::char(1) as dummycol\ |
|
|
|
|
into temp tmp_stud2\ |
|
|
|
|
from tmp_stud\ |
|
|
|
|
where 1=1\ |
|
|
|
|
/* ${<<Zusatzfilter>>} */\ |
|
|
|
|
group by\ |
|
|
|
|
<#list 1..groupby as i>${i}\ |
|
|
|
|
<#if i != groupby>\ |
|
|
|
|
,\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#list>\ |
|
|
|
|
;\ |
|
|
|
|
--für Prozentwerte alle Aggregate summieren:\ |
|
|
|
|
select <#foreach column in columns>\ |
|
|
|
|
<#if column.is_aggregate==1 && column.coltype!="computedColumn" && column.coltype!="processingColumn">\ |
|
|
|
|
sum(${column.targetfieldname})::float as ${column.targetfieldname},\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
null::char(1) as dummycol\ |
|
|
|
|
into temp tmp_gesamt\ |
|
|
|
|
from tmp_stud2\ |
|
|
|
|
where 1=1\ |
|
|
|
|
;\ |
|
|
|
|
\ |
|
|
|
|
<#assign number_of_visible_colums=0 />\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.is_visible!=0>\ |
|
|
|
|
<#assign number_of_visible_colums=number_of_visible_colums+1 />\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
<#assign colnr=0 />\ |
|
|
|
|
select \ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.is_visible!=0>\ |
|
|
|
|
<#assign colnr=colnr+1 />\ |
|
|
|
|
<#assign format_sql="" />\ |
|
|
|
|
<#if column.format_sql?string != "">\ |
|
|
|
|
<#assign format_sql=column.format_sql />\ |
|
|
|
|
</#if>\ |
|
|
|
|
\ |
|
|
|
|
<#if column.coltype=="computedColumn">\ |
|
|
|
|
(${column.colfunction})${format_sql} as ${column.targetfieldname}\ |
|
|
|
|
<#else>\ |
|
|
|
|
${column.targetfieldname}${format_sql} as ${column.targetfieldname}\ |
|
|
|
|
</#if>\ |
|
|
|
|
\ |
|
|
|
|
<#if colnr < number_of_visible_colums>,</#if>\ |
|
|
|
|
</#if> --wenn sichtbar\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
from tmp_stud2\ |
|
|
|
|
order by <#list 1..number_of_visible_colums as i>${i}\ |
|
|
|
|
<#if i != number_of_visible_colums>\ |
|
|
|
|
,\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#list>\ |
|
|
|
|
;\ |
|
|
|
|
<#if basetable.is_virtual==1>\ |
|
|
|
|
drop table if exists ${basetable.runtime_tablename};\ |
|
|
|
|
</#if>\ |
|
|
|
|
\ |
|
|
|
|
\ |
|
|
|
|
drop table if exists tmp_stud;\ |
|
|
|
|
drop table if exists tmp_stud2;\ |
|
|
|
|
drop table if exists tmp_gesamt;\ |
|
|
|
|
\ |
|
|
|
|
\ |
|
|
|
|
</#if> --wenn columns?has_content^--Freemarker Template\ |
|
|
|
|
XIL List\ |
|
|
|
|
sizable_columns horizontal_scrolling\ |
|
|
|
|
drop_and_delete movable_columns \ |
|
|
|
|
white_space_color=COLOR_WHITE fixed_columns=1\ |
|
|
|
|
min_heading_height=55\ |
|
|
|
|
<#foreach column in columns>\ |
|
|
|
|
<#if column.is_visible!=0>\ |
|
|
|
|
Column CID=0 heading_text="${column.caption}" center_heading explanation="${column.description}"\ |
|
|
|
|
row_selectable heading_platform readonly\ |
|
|
|
|
width=${column.visible_width} text_size=60\ |
|
|
|
|
</#if>\ |
|
|
|
|
</#foreach>\ |
|
|
|
|
@@@^Studienfach^Anzahl bzw. Anteil^Leistungen und Studiengänge^drop table if exists tmp_stud2; drop table if exists tmp_stud3;^^2^850^540^^1^<<SQL>>SELECT description FROM rpta_column_layout where tid=<<Spaltenlayout>>;^ |