From 90e1d5f7f7831392203aafa1daa75fe18a84674d Mon Sep 17 00:00:00 2001 From: Daniel Quathamer Date: Thu, 31 Oct 2024 15:09:51 +0100 Subject: [PATCH] =?UTF-8?q?Wartungsscripte=20Studierende=20und=20Studieng?= =?UTF-8?q?=C3=A4nge=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reset_sos_lab_stg_tid_stg.sql | 166 ++++++++++++++++++ .../studierende_loeschen.sql | 13 ++ 2 files changed, 179 insertions(+) create mode 100644 module/sos/sos_lab_stg_reset_tid_stg/reset_sos_lab_stg_tid_stg.sql create mode 100644 module/sos/studierende_loeschen/studierende_loeschen.sql diff --git a/module/sos/sos_lab_stg_reset_tid_stg/reset_sos_lab_stg_tid_stg.sql b/module/sos/sos_lab_stg_reset_tid_stg/reset_sos_lab_stg_tid_stg.sql new file mode 100644 index 0000000..6899886 --- /dev/null +++ b/module/sos/sos_lab_stg_reset_tid_stg/reset_sos_lab_stg_tid_stg.sql @@ -0,0 +1,166 @@ + +--Wenn es bei archivierten Daten Verweise in sos_lab_stg.tid_stg auf +--Nummern gibt, die es in lehr_stg_ab nicht gibt, +--können Sie mit diesem SQL die tid_stg zurücksetzen + +--Im Ergebnis darf der SQL: +-- select distinct tid_stg from sos_lab_stg where stichtag=4 +-- and tid_stg not in (select tid from lehr_stg_ab) +-- order by 1; +--keinen Datensatz liefern + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND sos_lab_stg.pversion_stg = L.pversion + AND sos_lab_stg.schwerpunkt_stg = L.schwerpunkt + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + AND L.stort = sos_lab_stg.stort + AND L.stutyp = sos_lab_stg.stutyp +); + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + AND L.stort = sos_lab_stg.stort + AND L.stutyp = sos_lab_stg.stutyp +) +WHERE tid_stg IS NULL; + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND sos_lab_stg.pversion_stg = L.pversion + AND sos_lab_stg.schwerpunkt_stg = L.schwerpunkt + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + AND L.stutyp = sos_lab_stg.stutyp +) +WHERE tid_stg IS NULL; + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND sos_lab_stg.schwerpunkt_stg = L.schwerpunkt + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + AND L.stutyp = sos_lab_stg.stutyp +) +WHERE tid_stg IS NULL; + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + AND L.stutyp = sos_lab_stg.stutyp + ) +WHERE tid_stg IS NULL; + +--jetzt ohne stutyp: +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach_stg = L.stg + AND sos_lab_stg.ch39_vertief_stg = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss_stg = L.abschluss + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach_stg + --AND L.stutyp = sos_lab_stg.stutyp + ) +WHERE tid_stg IS NULL; + +-- wenn Studiengang des Studierenden nicht ermittelt werden kann, +-- nehmen wir als fallback die Angaben der Prüfung: +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach = L.stg + AND sos_lab_stg.ch39_vertief = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss = L.abschluss + AND sos_lab_stg.pversion = L.pversion + AND sos_lab_stg.schwerpunkt = L.schwerpunkt + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach + AND L.stutyp = sos_lab_stg.stutyp + ) +WHERE tid_stg IS NULL; + +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach = L.stg + AND sos_lab_stg.ch39_vertief = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss = L.abschluss + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach + AND L.stutyp = sos_lab_stg.stutyp + ) +WHERE tid_stg IS NULL; + +--jetzt ohne stutyp: +UPDATE sos_lab_stg +SET tid_stg = ( + SELECT min(tid) + FROM + lehr_stg_ab L + WHERE + sos_lab_stg.ch30_fach = L.stg + AND sos_lab_stg.ch39_vertief = L.vertfg + AND sos_lab_stg.ch35_ang_abschluss = L.abschluss + AND L.semester_von <= sos_lab_stg.sem_der_pruefung + AND L.semester_bis >= sos_lab_stg.sem_der_pruefung + AND L.kz_fach = sos_lab_stg.kz_fach + --AND L.stutyp = sos_lab_stg.stutyp + ) +WHERE tid_stg IS NULL; diff --git a/module/sos/studierende_loeschen/studierende_loeschen.sql b/module/sos/studierende_loeschen/studierende_loeschen.sql new file mode 100644 index 0000000..63279ae --- /dev/null +++ b/module/sos/studierende_loeschen/studierende_loeschen.sql @@ -0,0 +1,13 @@ +--freemarker template +--Lösche Teststudenten: +<#assign mtknr="9991,9992,9993,9994,9995,9996,9997,9998,9999,203508,203510,203514,376677,379874,386001,386006,404376" /> + + +delete from sos_sos where matrikel_nr in (${mtknr}); +delete from sos_stg where matrikel_nr in (${mtknr}); +delete from sos_stg_aggr where matrikel_nr in (${mtknr}); +delete from sos_lab where matrikel_nr in (${mtknr}); +delete from sos_lab_stg where matrikel_nr in (${mtknr}); +delete from sos_stg_verlauf where matrikel_nr in (${mtknr}); + +