|
|
|
|
|
|
|
delete from costage_st_studierendenstammdaten;
|
|
|
|
|
|
|
|
--zuerst Ermittlung max. Semester
|
|
|
|
select S.st_studstamm_nr,max(SM.semester_tid)::integer as semester_max
|
|
|
|
into temp tmp_max
|
|
|
|
from costage_st_studierendenstammdaten_neu S,
|
|
|
|
costage_st_studien ST,
|
|
|
|
costage_st_semester SM,
|
|
|
|
costage_st_studienstatus SA
|
|
|
|
where S.st_studstamm_nr = ST.st_studstamm_nr
|
|
|
|
and SA.st_studium_nr=ST.st_studium_nr
|
|
|
|
and SA.st_sem_nr=SM.st_sem_nr
|
|
|
|
and SA.studienstatustyp not in ('a','o')
|
|
|
|
and S.matrikelnummer is not null
|
|
|
|
group by 1
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
insert into costage_st_studierendenstammdaten(
|
|
|
|
st_studstamm_nr,
|
|
|
|
matrikelnummer,
|
|
|
|
vorname,
|
|
|
|
familienname,
|
|
|
|
geburtsdatum,
|
|
|
|
st_land1_nr,
|
|
|
|
st_land2_nr,
|
|
|
|
geburt_st_land_nr,
|
|
|
|
personentyp_name,
|
|
|
|
personentyp_kb,
|
|
|
|
aufnahmedatum,
|
|
|
|
abmeldungsdatum,
|
|
|
|
geschlecht,
|
|
|
|
ca12_staat,
|
|
|
|
second_nationality,
|
|
|
|
d_geburt,
|
|
|
|
d_exmatr,
|
|
|
|
semester_max)
|
|
|
|
select
|
|
|
|
S.st_studstamm_nr,
|
|
|
|
val(S.matrikelnummer),
|
|
|
|
vorname,
|
|
|
|
familienname,
|
|
|
|
geburtsdatum,
|
|
|
|
st_land1_nr,
|
|
|
|
st_land2_nr,
|
|
|
|
geburt_st_land_nr,
|
|
|
|
personentyp_name,
|
|
|
|
personentyp_kb,
|
|
|
|
aufnahmedatum,
|
|
|
|
abmeldungsdatum,
|
|
|
|
(case when S.geschlecht='M' then 1
|
|
|
|
when S.geschlecht='W' then 2
|
|
|
|
when S.geschlecht='X' then 3
|
|
|
|
else 4 end)::smallint as geschlecht,
|
|
|
|
val(L.statistik_code) as ca12_staat,
|
|
|
|
S.st_land2_nr,
|
|
|
|
date(S.geburtsdatum) as d_geburt,
|
|
|
|
date(S.abmeldungsdatum) as d_exmatr,
|
|
|
|
M.semester_max
|
|
|
|
FROM costage_st_laender L, costage_st_studierendenstammdaten_neu S left outer join tmp_max M
|
|
|
|
on (M.st_studstamm_nr=S.st_studstamm_nr)
|
|
|
|
where L.st_land_nr=S.st_land1_nr
|
|
|
|
and S.matrikelnummer is not null
|
|
|
|
;
|
|
|
|
|
|
|
|
update costage_st_studierendenstammdaten set second_nationality=val(L.statistik_code)
|
|
|
|
from costage_st_laender L
|
|
|
|
where L.st_land_nr=costage_st_studierendenstammdaten.st_land2_nr;
|
|
|
|
|
|
|
|
|
|
|
|
drop table tmp_max;
|
|
|
|
|