@ -103,12 +103,38 @@ and hoererstatus_kb != 'E' --der Hörerstatus "E - Exmatrikuliert" gilt eigentli
@@ -103,12 +103,38 @@ and hoererstatus_kb != 'E' --der Hörerstatus "E - Exmatrikuliert" gilt eigentli
;
- - tmp_studien enthält TSG , ESG und MSG
- - wir machen den MSG von einer Zeile zu einer Spalte
- - zuerst die msg :
drop table if exists tmp_studien_msg ;
select
st_absz_nr ,
st_skz_nr ,
studiengangs_identifikator ,
studiengangs_bezeichnung ,
st_studium_nr ,
st_studstamm_nr ,
st_studiengang_nr ,
studienstatustyp ,
st_studienstatus_nr ,
beginn_datum ,
gueltig_ab ,
semester ,
primaerflag_studien ,
hrst
into temp tmp_studien_msg
from tmp_studien T where T . studiengangs_typ_kb in ( ' MSG ' )
and T . status_historie = 1
;
select 10 , timestamp_str ( now ( ) ) from xdummy ;
- - wir machen den MSG von einer Zeile zu einer Spalte
- - 1 . Prio TSG hat Primärflag :
drop table if exists tmp_studien_esg_tsg ;
select * ,
1 : : integer as primaerflag ,
null : : integer as letztes_tsg_semester
null : : integer as letztes_tsg_semester ,
null : : integer as st_studium_nr_msg
into temp tmp_studien_esg_tsg from tmp_studien T
where T . studiengangs_typ_kb in ( ' ESG ' , ' TSG ' )
and T . status_historie = 1
@ -119,7 +145,8 @@ and T.status_historie=1
@@ -119,7 +145,8 @@ and T.status_historie=1
insert into tmp_studien_esg_tsg
select T . * ,
( case when H . st_studstamm_nr > 0 then 1 : : integer else 0 : : integer end ) as primaerflag ,
null : : integer as letztes_tsg_semester
null : : integer as letztes_tsg_semester ,
null : : integer as st_studium_nr_msg
from tmp_studien T left outer join costage_st_hauptstudien H
on ( H . st_studstamm_nr = T . st_studstamm_nr
and H . st_studium_nr = T . st_studium_nr
@ -129,7 +156,34 @@ from tmp_studien T left outer join costage_st_hauptstudien H
@@ -129,7 +156,34 @@ from tmp_studien T left outer join costage_st_hauptstudien H
and T . primaerflag_studien = 0
;
update tmp_studien_esg_tsg set st_studium_nr_msg = MSG . st_studium_nr
from tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where tmp_studien_esg_tsg . studiengangs_typ_kb in ( ' TSG ' )
and tmp_studien_esg_tsg . semester = MSG . semester
and tmp_studien_esg_tsg . st_studstamm_nr = MSG . st_studstamm_nr
and tmp_studien_esg_tsg . st_studiengang_nr = MTSG . st_studiengang_nr_tsg
and tmp_studien_esg_tsg . st_absz_nr = MSG . st_absz_nr
and MSG . st_studiengang_nr = MTSG . st_studiengang_nr_msg
and MSG . primaerflag_studien = 1
;
select 20 , timestamp_str ( now ( ) ) from xdummy ;
update tmp_studien_esg_tsg set st_studium_nr_msg = MSG . st_studium_nr
from tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where tmp_studien_esg_tsg . st_studium_nr_msg is null
and tmp_studien_esg_tsg . studiengangs_typ_kb in ( ' TSG ' )
and tmp_studien_esg_tsg . semester = MSG . semester
and tmp_studien_esg_tsg . st_studstamm_nr = MSG . st_studstamm_nr
and tmp_studien_esg_tsg . st_studiengang_nr = MTSG . st_studiengang_nr_tsg
and tmp_studien_esg_tsg . st_absz_nr = MSG . st_absz_nr
and MSG . st_studiengang_nr = MTSG . st_studiengang_nr_msg
and MSG . primaerflag_studien = 0
;
select 30 , timestamp_str ( now ( ) ) from xdummy ;
update tmp_studien_esg_tsg
@ -140,6 +194,7 @@ and F.st_sem_nr=tmp_studien_esg_tsg.st_sem_nr
@@ -140,6 +194,7 @@ and F.st_sem_nr=tmp_studien_esg_tsg.st_sem_nr
and F . fachsemestertyp = ' FS '
;
select 40 , timestamp_str ( now ( ) ) from xdummy ;
update tmp_studien_esg_tsg
set hzb_art_nr = H . hzb_art_nr ,
@ -158,7 +213,7 @@ from costage_st_hzb H
@@ -158,7 +213,7 @@ from costage_st_hzb H
where tmp_studien_esg_tsg . st_studstamm_nr = H . st_person_nr
;
select 1 0, timestamp_str ( now ( ) ) from xdummy ;
select 5 0, timestamp_str ( now ( ) ) from xdummy ;
- - Abmeldungsart studienbezogen :
update tmp_studien_esg_tsg set abm_art_s = P . st_abm_art_kurzbezeichnung
@ -171,191 +226,32 @@ and A.bezug='S'
@@ -171,191 +226,32 @@ and A.bezug='S'
;
select 20 , timestamp_str ( now ( ) ) from xdummy ;
create index tmp_ix3 on tmp_studien ( studiengangs_typ_kb ) ;
create index tmp_ix5 on tmp_studien ( status_historie ) ;
create index tmp_ix6 on tmp_studien ( primaerflag_studien ) ;
-- --Primärflag ermitteln:
-- --1. Prio: aus px_st_studien_v:
-- select T.*,
-- 1::integer as primaerflag,
-- null::integer as letztes_tsg_semester
-- into temp tmp_studien2
-- from tmp_studien T
-- where T.status_historie=1
-- and T.studiengangs_typ_kb in ('ESG','TSG')
-- and T.primaerflag_studien=1
-- ;
--
-- --2. Prio: aus costage_st_hauptstudien:
-- insert into tmp_studien2
-- select T.*,
-- (case when H.st_studstamm_nr > 0 then 1::integer else 0::integer end) as primaerflag,
-- null::integer as letztes_tsg_semester
-- from tmp_studien T left outer join costage_st_hauptstudien H
-- on ( H.st_studstamm_nr=T.st_studstamm_nr
-- and H.st_studium_nr=T.st_studium_nr
-- and H.st_sem_nr=T.st_sem_nr)
-- where T.status_historie=1
-- and T.studiengangs_typ_kb in ('ESG','TSG')
-- and T.primaerflag_studien=0
-- ;
select 30 , timestamp_str ( now ( ) ) from xdummy ;
- - Studiengänge ohne Primärflag TODO langsam :
-- insert into tmp_studien2
-- select T.*,
-- 0::integer as primaerflag,
-- null::integer as letztes_tsg_semester
-- from tmp_studien T left outer join costage_st_hauptstudien H
-- on (H.st_studstamm_nr=T.st_studstamm_nr
-- and H.st_studium_nr=T.st_studium_nr
-- and H.st_sem_nr=T.st_sem_nr)
-- where T.status_historie=1
-- and T.studiengangs_typ_kb in ('ESG','TSG')
-- and T.primaerflag_studien=0
-- and H.st_studstamm_nr is null
-- ;
-- create index tmp_ix2_1 on tmp_studien2(st_studiengang_nr);
-- create index tmp_ix2_2 on tmp_studien2(st_studstamm_nr);
-- create index tmp_ix2_3 on tmp_studien2(studiengangs_typ_kb);
-- create index tmp_ix2_4 on tmp_studien2(st_sem_nr);
-- create index tmp_ix2_7 on tmp_studien2(st_absz_nr);
select 40 , timestamp_str ( now ( ) ) from xdummy ;
- - Ermittlung msg bei TSG :
drop table if exists tmp_studien_msg ;
select
st_absz_nr ,
st_skz_nr ,
studiengangs_identifikator ,
studiengangs_bezeichnung ,
st_studium_nr ,
st_studstamm_nr ,
st_studiengang_nr ,
studienstatustyp ,
st_studienstatus_nr ,
beginn_datum ,
gueltig_ab ,
semester ,
primaerflag_studien ,
hrst
into temp tmp_studien_msg
from tmp_studien T where T . studiengangs_typ_kb in ( ' MSG ' )
and T . status_historie = 1
;
- - es kann pro Studi und Semester und Abschlussziel mehrere MSG geben ,
- - daqher zuerst den jeweils letzten ermitteln . Dieser ist dann der Default - MSG :
drop table if exists tmp_tsg2msg ;
- - wie viele gleichzeitige MSG pro TSG gibt es ?
select TSG . semester ,
TSG . st_studstamm_nr ,
TSG . st_studium_nr as st_studium_nr_tsg ,
min ( MSG . beginn_datum ) as beginn_datum_msg ,
max ( MSG . primaerflag_studien ) as primaerflag_studien_msg ,
count ( distinct MSG . st_studium_nr ) as anzahl_st_studium_nr_msg
into temp tmp_tsg2msg
from tmp_studien_esg_tsg TSG , tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where TSG . studiengangs_typ_kb in ( ' TSG ' )
and TSG . semester = MSG . semester
and TSG . st_studstamm_nr = MSG . st_studstamm_nr
and TSG . st_studiengang_nr = MTSG . st_studiengang_nr_tsg
and TSG . st_absz_nr = MSG . st_absz_nr
and MSG . st_studiengang_nr = MTSG . st_studiengang_nr_msg
group by 1 , 2 , 3
;
- - create index tmp_ix222 on tmp_tsg2msg ( primaerflag_studien ) ;
- - select * from tmp_tsg2msg ;
select 60 , timestamp_str ( now ( ) ) from xdummy ;
drop table if exists tmp_studien_tsg ;
- - studiengänge mit 1 MSG werden zuerst selektiert :
select TSG . * , T . primaerflag_studien_msg , MTSG . st_studiengang_nr_msg , MSG . st_studium_nr as st_studium_nr_msg ,
select ETSG . * ,
MSG . primaerflag_studien as primaerflag_studien_msg ,
MTSG . st_studiengang_nr_msg ,
MTSG . studienfach_sortierung
into temp tmp_studien_tsg
from tmp_studien_esg_tsg TSG , tmp_tsg2msg T , tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where T . semester = TSG . semester
and MSG . semester = TSG . semester
and T . st_studstamm_nr = TSG . st_studstamm_nr
and MSG . st_studstamm_nr = TSG . st_studstamm_nr
and MTSG . st_studiengang_nr_tsg = TSG . st_studiengang_nr
and MTSG . st_studiengang_nr_msg = MSG . st_studiengang_nr
and T . st_studium_nr_tsg = TSG . st_studium_nr
and TSG . studiengangs_typ_kb in ( ' TSG ' )
and T . anzahl_st_studium_nr_msg = 1
;
drop table if exists tmp_studien_tsg_mehrere_msg ;
- - studiengänge mit 2 oder mehr MSG werden ü ber min ( studium ) ermittelt :
select TSG . semester ,
TSG . st_studstamm_nr ,
TSG . st_studium_nr ,
T . primaerflag_studien_msg ,
TSG . st_studiengang_nr as st_studiengang_nr_tsg ,
null : : integer as st_studiengang_nr_msg ,
null : : integer as studienfach_sortierung ,
min ( MSG . st_studium_nr ) as st_studium_nr_msg
into temp tmp_studien_tsg_mehrere_msg
from tmp_studien_esg_tsg TSG , tmp_tsg2msg T , tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where T . semester = TSG . semester
and MSG . semester = TSG . semester
and T . st_studstamm_nr = TSG . st_studstamm_nr
and MSG . st_studstamm_nr = TSG . st_studstamm_nr
and MTSG . st_studiengang_nr_tsg = TSG . st_studiengang_nr
from tmp_studien_esg_tsg ETSG , tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where
MSG . semester = ETSG . semester
and MSG . st_studium_nr = ETSG . st_studium_nr_msg
and MSG . st_studstamm_nr = ETSG . st_studstamm_nr
and MTSG . st_studiengang_nr_tsg = ETSG . st_studiengang_nr
and MTSG . st_studiengang_nr_msg = MSG . st_studiengang_nr
and T . st_studium_nr_tsg = TSG . st_studium_nr
and TSG . studiengangs_typ_kb in ( ' TSG ' )
and T . anzahl_st_studium_nr_msg > 1
group by 1 , 2 , 3 , 4 , 5
;
update tmp_studien_tsg_mehrere_msg set st_studiengang_nr_msg = MSG . st_studiengang_nr ,
studienfach_sortierung = MTSG . studienfach_sortierung
from tmp_studien_msg MSG , costage_st_studiengaenge_mtsg MTSG
where MSG . st_studiengang_nr = MTSG . st_studiengang_nr_msg
and tmp_studien_tsg_mehrere_msg . st_studiengang_nr_tsg = MTSG . st_studiengang_nr_tsg
and MSG . semester = tmp_studien_tsg_mehrere_msg . semester
and MSG . st_studstamm_nr = tmp_studien_tsg_mehrere_msg . st_studstamm_nr
and MSG . st_studium_nr = tmp_studien_tsg_mehrere_msg . st_studium_nr_msg ;
insert into tmp_studien_tsg
select TSG . * , T . primaerflag_studien_msg ,
M . st_studiengang_nr_msg ,
M . st_studium_nr_msg ,
M . studienfach_sortierung
from tmp_studien_esg_tsg TSG , tmp_tsg2msg T , tmp_studien_tsg_mehrere_msg M
where T . semester = TSG . semester
and M . semester = TSG . semester
and T . st_studstamm_nr = TSG . st_studstamm_nr
and M . st_studstamm_nr = TSG . st_studstamm_nr
and T . st_studium_nr_tsg = TSG . st_studium_nr
and M . st_studium_nr = TSG . st_studium_nr
and TSG . studiengangs_typ_kb in ( ' TSG ' )
and T . anzahl_st_studium_nr_msg > 1
;
and ETSG . studiengangs_typ_kb in ( ' TSG ' ) ;
- - 1 . prio : primärflag = 1
select 45 , timestamp_str ( now ( ) ) from xdummy ;
create index tmp_ix3 on tmp_studien ( studiengangs_typ_kb ) ;
create index tmp_ix5 on tmp_studien ( status_historie ) ;
create index tmp_ix6 on tmp_studien ( primaerflag_studien ) ;
- - statustyp bei TSG aus MSG nachladen :
update tmp_studien_tsg set studienstatustyp = S . studienstatustyp ,
studiengangs_identifikator_msg = S . studiengangs_identifikator
@ -397,17 +293,6 @@ group by 1,2,3
@@ -397,17 +293,6 @@ group by 1,2,3
select 90 , timestamp_str ( now ( ) ) from xdummy ;
- - letzten MSG zuweisen :
-- update tmp_studien_msg_tsg set st_studiengang_nr_msg_end=ST.st_studiengang_nr
-- from costage_st_studiengaenge_mtsg M, tmp_studien ST
-- where ST.st_studiengang_nr=M.st_studiengang_nr_msg
-- and M.st_studiengang_nr_tsg=tmp_studien_msg_tsg.st_studiengang_nr_tsg
-- and ST.st_studstamm_nr=tmp_studien_msg_tsg.st_studstamm_nr
-- and ST.semester = tmp_studien_msg_tsg.endsemester_msg
-- and ST.studiengangs_typ_kb ='MSG'
-- and ST.studienstatustyp in ('U','B','E','I','X','Z') --nur tatsächlich eingeschrieben
-- and ST.status_historie=1
-- ;
select 100 , timestamp_str ( now ( ) ) from xdummy ;