@ -8,12 +8,16 @@ select count(*) from rpta_resultset where uniquename='rpta_exam_unit_dim_studien
select uniquename from rpta_resultset where uniquename = ' rpta_exam_unit_dim_studiengang ' ;
select uniquename from rpta_resultset where uniquename = ' rpta_exam_unit_dim_studiengang ' ;
< / sqlvar >
< / sqlvar >
< / sqlvars >
< / sqlvars >
< #assign rpta_column_layouts = [ {"uniquename":"rpta_exam_unit_dim_studiengang_note",
< #assign rpta_column_layout = {"uniquename":"rpta_exam_unit_dim_studiengang_note",
" caption " : " Prüfungsergebnisse " ,
" caption " : " Prüfungsergebnisse " ,
" rpta_resultset " : " rpta_exam_unit_dim_studiengang " ,
" rpta_resultset " : " rpta_exam_unit_dim_studiengang " ,
" whereclause " : " ((modulart=''P'' and sourcesystem=6) or (part=''MP'' and sourcesystem=5)) " ,
" whereclause " : " ((modulart=''P'' and sourcesystem=6) or (part=''MP'' and sourcesystem=5))
and pstatus in ( ' ' BE ' ' , ' ' NB ' ' , ' ' EN ' ' )
and ( ( ( panerk ! = ' ' J ' ' and sourcesystem = 6 ) or ( panerk is null and sourcesystem = 6 ) )
or ( ( panerk ! = ' ' I ' ' and panerk ! = ' ' J ' ' and panerk ! = ' ' H ' ' and sourcesystem = 5 ) or ( panerk is null and sourcesystem = 5 ) ) ) " ,
" sortclause " : " dim_studiengang_stg,dim_studiengang_abschluss,sem_der_pruefung,pdtxt " ,
" description " : " Prüfung und Noten "
" description " : " Prüfung und Noten "
} ]
}
/ >
/ >
< #assign rpta_columns = [
< #assign rpta_columns = [
@ -209,234 +213,7 @@ select uniquename from rpta_resultset where uniquename='rpta_exam_unit_dim_studi
] / >
] / >
- - - ab hier nicht mehr ä ndern :
< @ rpta_column_layout_fuellen / >
CREATE temp TABLE tmp_rpta_column
(
uniquename varchar ( 255 ) NOT NULL ,
caption 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 ,
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 ,
description text
) ;
< #foreach rpta_column_layout in rpta_column_layouts>
insert into tmp_rpta_column_layout (
resultset_id ,
uniquename ,
caption ,
whereclause ,
description
)
select tid ,
' ${rpta_column_layout.uniquename} ' ,
' ${rpta_column_layout.caption} ' ,
' ${rpta_column_layout.whereclause} ' ,
' ${rpta_column_layout.description} '
FROM rpta_resultset
where uniquename = ' ${rpta_column_layout.rpta_resultset} ' ;
< / #foreach >
< #assign sortnr=0 />
< #foreach column in rpta_columns>
< #assign sortnr=sortnr +1 />
INSERT INTO tmp_rpta_column
( resultset_id ,
uniquename ,
caption ,
srcfieldname ,
targetfieldname ,
column_type ,
col_function ,
is_visible ,
visible_size ,
is_aggregate ,
sortnr ,
description ,
format_code_uniquename
)
select R . tid ,
' ${column.uniquename} ' ,
' ${column.caption} ' ,
' ${column.srcfieldname} ' ,
< #if !column.targetfieldname?exists || column.targetfieldname=="">null::varchar <#else>'${column.targetfieldname}' </#if>,
T . tid as column_type ,
< #if column.col_function?exists>'${column.col_function}'<#else>null::varchar </#if>,
$ { column . is_visible } ,
$ { column . visible_size } ,
$ { column . is_aggregate } ,
$ { sortnr * 10 } ,
< #if column.description?exists>'${column.description}'<#else>null::varchar </#if>,
< #if column.format_code?exists>'${column.format_code}'<#else>null::varchar </#if>
FROM rpta_resultset R , rpta_column_type T
where R . uniquename = ' ${rpta_resultset} '
and T . uniquename = ' ${column.column_type} ' ;
< / #foreach>
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 = ' ${rpta_resultset} '
and L . uniquename in (
< #foreach rpta_column_layout in rpta_column_layouts>
' ${rpta_column_layout.uniquename} ' ,
< / #foreach>'xy')
)
;
select * into temp tmp_rpta_column_layout_target
from rpta_column_layout
where resultset_id in ( select tid
FROM rpta_resultset
where uniquename = ' ${rpta_resultset} ' )
and uniquename in ( select uniquename from tmp_rpta_column_layout )
;
insert into rpta_column_layout
( uniquename ,
caption ,
resultset_id ,
whereclause ,
description )
select uniquename ,
caption ,
resultset_id ,
whereclause ,
description
FROM tmp_rpta_column_layout T
where 0 = ( select count ( * ) from tmp_rpta_column_layout_target T2
where T . uniquename = T2 . uniquename ) ;
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 = ' ${rpta_resultset} '
and L . uniquename in (
< #foreach rpta_column_layout in rpta_column_layouts>
' ${rpta_column_layout.uniquename} ' ,
< / #foreach>'xy')
)
;
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 ,
T . description ,
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 in (
< #foreach rpta_column_layout in rpta_column_layouts>
' ${rpta_column_layout.uniquename} ' ,
< / #foreach>'xy')
and L . resultset_id = T . resultset_id
;
drop table tmp_rpta_column ;
drop table if exists tmp_rpta_column2 ;
drop TABLE tmp_rpta_column_layout ;