4 changed files with 205 additions and 2 deletions
@ -0,0 +1,100 @@ |
|||||||
|
--(c) 2025 D.Quathamer |
||||||
|
--Das Script identifiziert Duplikate in der lehr_stg_ab und entfernt diese |
||||||
|
-- eingefrorene Stichtagsdaten werden korrigiert, damit die Datenintegrität bleibt |
||||||
|
-- Achtung: Das Script ist nur nutzbar bis SOS 1.5 / HISinOne-BI 2025.06. |
||||||
|
-- Beim SOS Modul 1.6 /HISinOne-BI 2025.12 muss das Script angepaßt werden, |
||||||
|
-- weil da die Studienform hinzukommt. |
||||||
|
|
||||||
|
drop table if exists tmp_doppelt; |
||||||
|
|
||||||
|
select stg, |
||||||
|
vertfg, |
||||||
|
schwerpunkt, |
||||||
|
pversion, |
||||||
|
kz_fach, |
||||||
|
abschluss, |
||||||
|
stort, |
||||||
|
stutyp, |
||||||
|
null::integer as tid_richtig |
||||||
|
into temp tmp_doppelt |
||||||
|
from lehr_stg_ab |
||||||
|
group by 1,2,3,4,5,6,7,8 |
||||||
|
having count(*)>1; |
||||||
|
|
||||||
|
update tmp_doppelt D set tid_richtig=(select min(L.tid) |
||||||
|
from lehr_stg_ab L |
||||||
|
where D.pversion=L.pversion |
||||||
|
and D.kz_fach=L.kz_fach |
||||||
|
and D.stort=L.stort |
||||||
|
and D.abschluss=L.abschluss |
||||||
|
and D.stg=L.stg |
||||||
|
and D.vertfg=L.vertfg |
||||||
|
and D.schwerpunkt=L.schwerpunkt |
||||||
|
and D.stutyp=L.stutyp); |
||||||
|
|
||||||
|
drop table if exists tmp_pos; |
||||||
|
|
||||||
|
|
||||||
|
select L.stg, |
||||||
|
L.vertfg, |
||||||
|
L.schwerpunkt, |
||||||
|
L.pversion, |
||||||
|
L.kz_fach, |
||||||
|
L.abschluss, |
||||||
|
L.stort, |
||||||
|
L.stutyp, |
||||||
|
L.tid , |
||||||
|
D.tid_richtig as tid_stu |
||||||
|
into temp tmp_pos |
||||||
|
from lehr_stg_ab L, tmp_doppelt D |
||||||
|
where D.pversion=L.pversion |
||||||
|
and D.kz_fach=L.kz_fach |
||||||
|
and D.stort=L.stort |
||||||
|
and D.abschluss=L.abschluss |
||||||
|
and D.stg=L.stg |
||||||
|
and D.vertfg=L.vertfg |
||||||
|
and D.schwerpunkt=L.schwerpunkt |
||||||
|
and D.stutyp=L.stutyp; |
||||||
|
|
||||||
|
delete from tmp_pos where tid=tid_stu; |
||||||
|
--Protokoll: |
||||||
|
|
||||||
|
|
||||||
|
--bereinigen: |
||||||
|
begin work; |
||||||
|
|
||||||
|
|
||||||
|
update sos_stg_aggr set tid_stg =(select K.tid_stu |
||||||
|
from tmp_pos K |
||||||
|
where K.tid=sos_stg_aggr.tid_stg) |
||||||
|
where tid_stg in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
|
||||||
|
update sos_lab_stg set tid_stg =(select K.tid_stu |
||||||
|
from tmp_pos K |
||||||
|
where K.tid=sos_lab_stg.tid_stg) |
||||||
|
where tid_stg in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
|
||||||
|
update sos_lab_aggr set tid_stg =(select K.tid_stu |
||||||
|
from tmp_pos K |
||||||
|
where K.tid=sos_lab_aggr.tid_stg) |
||||||
|
where tid_stg in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
|
||||||
|
delete from gang_stg_ab where tid in (select G.gang_tid |
||||||
|
from gang_lehr_stg_ab G, tmp_pos K |
||||||
|
where G.lehr_stg_ab_tid=K.tid |
||||||
|
and K.tid_stu is not null); |
||||||
|
|
||||||
|
delete from gang_lehr_stg_ab |
||||||
|
where |
||||||
|
lehr_stg_ab_tid in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
|
||||||
|
|
||||||
|
delete from lehr_stg_ab where tid in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
delete from dim_studiengang where tid in (select T.tid from tmp_pos T where T.tid_stu is not null); |
||||||
|
|
||||||
|
drop table tmp_pos; |
||||||
|
|
||||||
|
commit; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,95 @@ |
|||||||
|
--freemarker template |
||||||
|
--dieses Script entfernt arbiträre Fachschlüssel, |
||||||
|
--wenn diese (zeitweise) einen doppelten uniquename in H1 hatten. |
||||||
|
--Beispiel: zwei Fächer in STU hatten eine Zeit lang den gleichen uniquename, |
||||||
|
--in BI hat das eine Fach 550, und das Duplikat hat _086290 |
||||||
|
--der alte Schlüssel _086290 wird aus der eduetl-DB entfernt, und Verweise auf dieses Fach |
||||||
|
-- werden auf das neue Fach korrigiert. |
||||||
|
|
||||||
|
--Voraussetzung: der Fachschlüssel ist mittlerweile in STU eindeutig! |
||||||
|
|
||||||
|
<#assign stg_umschluesseln = [ |
||||||
|
{"alt":"_123590", "neu":"0104"}, |
||||||
|
{"alt":"_86287", "neu":"048"}, |
||||||
|
{"alt":"_86288", "neu":"0550"}, |
||||||
|
{"alt":"_123591", "neu":"0566"}, |
||||||
|
{"alt":"_56957", "neu":"0J39"}, |
||||||
|
{"alt":"_123588", "neu":"104"}, |
||||||
|
{"alt":"_86290", "neu":"550"}, |
||||||
|
{"alt":"_123589", "neu":"566"}, |
||||||
|
{"alt":"_56956", "neu":"566"}, |
||||||
|
{"alt":"_86289", "neu":"588"} |
||||||
|
|
||||||
|
|
||||||
|
] /> |
||||||
|
|
||||||
|
|
||||||
|
<#foreach stg in stg_umschluesseln> |
||||||
|
|
||||||
|
--zuerst lehr_stg_ab: |
||||||
|
select *, null::integer as tid_neu into temp tmp_alt |
||||||
|
from lehr_stg_ab where stg='${stg.alt}'; |
||||||
|
|
||||||
|
--für welche gibt es in lehr_stg_ab schon Datensätze mit stg.neu? |
||||||
|
update tmp_alt set tid_neu=(select L.tid |
||||||
|
from lehr_stg_ab L where L.stg='${stg.neu}' |
||||||
|
and L.pversion=tmp_alt.pversion |
||||||
|
and L.kz_fach=tmp_alt.kz_fach |
||||||
|
and L.stort=tmp_alt.stort |
||||||
|
and L.abschluss=tmp_alt.abschluss |
||||||
|
and L.vertfg=tmp_alt.vertfg |
||||||
|
and L.schwerpunkt=tmp_alt.schwerpunkt |
||||||
|
and L.semester_von=tmp_alt.semester_von |
||||||
|
and L.stutyp=tmp_alt.stutyp); |
||||||
|
--umzuschlüsseln: |
||||||
|
|
||||||
|
update sos_stg_aggr set tid_stg=T.tid_neu |
||||||
|
from tmp_alt T |
||||||
|
where sos_stg_aggr.tid_stg=T.tid |
||||||
|
and sos_stg_aggr.tid_stg in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where tid_neu is not null); |
||||||
|
|
||||||
|
update sos_lab_stg set tid_stg=T.tid_neu |
||||||
|
from tmp_alt T |
||||||
|
where sos_lab_stg.tid_stg=T.tid |
||||||
|
and sos_lab_stg.tid_stg in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where tid_neu is not null); |
||||||
|
|
||||||
|
update lm_konto_pro_fs set tid_stg=T.tid_neu |
||||||
|
from tmp_alt T |
||||||
|
where lm_konto_pro_fs.tid_stg=T.tid |
||||||
|
and lm_konto_pro_fs.tid_stg in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where tid_neu is not null); |
||||||
|
|
||||||
|
|
||||||
|
update gang_lehr_stg_ab set lehr_stg_ab_tid=T.tid_neu |
||||||
|
from tmp_alt T |
||||||
|
where gang_lehr_stg_ab.lehr_stg_ab_tid=T.tid |
||||||
|
and gang_lehr_stg_ab.lehr_stg_ab_tid in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where T2.tid_neu is not null); |
||||||
|
|
||||||
|
|
||||||
|
--danach löschen: |
||||||
|
delete from lehr_stg_ab where tid in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where T2.tid_neu is not null); |
||||||
|
|
||||||
|
--weitere Datensätze einfach updaten: |
||||||
|
update lehr_stg_ab set stg='${stg.neu}' where tid in (select T2.tid |
||||||
|
from tmp_alt T2 |
||||||
|
where T2.tid_neu is null); |
||||||
|
|
||||||
|
delete from cifx where key=30 and apnr = '${stg.alt}'; |
||||||
|
delete from trans_cifx where key=30 and apnr = '${stg.alt}'; |
||||||
|
|
||||||
|
drop table tmp_alt; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</#foreach> |
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in new issue