Browse Source

cd

grant statements refined #1
master
Daniel Quathamer 2 weeks ago
parent
commit
bd1a8e7b60
  1. 5
      module/fin/hisrm_dbrechte_beispiel/fin_unload_tabellen_mbs_grant.sql
  2. 100
      module/sos/duplikate_lehr_stg_ab/duplikate_lehr_stg_ab_entfernen.sql
  3. 95
      module/sos/stg_umschluesseln/sos_und_gang_stg_umschluesseln.sql
  4. 7
      module/sva/hisrm_dbrechte_beispiel/sva_unload_tabellen_sva4_grant.sql

5
module/fin/hisrm_dbrechte_beispiel/fin_unload_tabellen_mbs_grant.sql

@ -1,6 +1,7 @@
create user biuser; --Wenn Sie die Standard-Kennung im Vorsystem nutzen, hat diese vermutlich mehr Rechte als nötig. Für die BI-Entladescripte benötigen Sie in der Regel nur Leserecht und dies auch nur für einzelne Tabellen.
--Sie können also z.B. einen User "biuser" in HISRM anlegen, mit folgenden Berechtigungen:
alter USER biuser WITH NOSUPERUSER PASSWORD 'anfang13'; CREATE USER biuser WITH NOSUPERUSER PASSWORD 'xxx';
GRANT usage ON SCHEMA mbs TO biuser; GRANT usage ON SCHEMA mbs TO biuser;
GRANT SELECT ON TABLE mbs.bga_to_mbs TO biuser; GRANT SELECT ON TABLE mbs.bga_to_mbs TO biuser;

100
module/sos/duplikate_lehr_stg_ab/duplikate_lehr_stg_ab_entfernen.sql

@ -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;

95
module/sos/stg_umschluesseln/sos_und_gang_stg_umschluesseln.sql

@ -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>

7
module/sva/hisrm_dbrechte_beispiel/sva_unload_tabellen_sva4_grant.sql

@ -1,3 +1,10 @@
--Wenn Sie die Standard-Kennung im Vorsystem nutzen, hat diese vermutlich mehr Rechte als nötig. Für die BI-Entladescripte benötigen Sie in der Regel nur Leserecht und dies auch nur für einzelne Tabellen.
--
-- Ausnahme von dieser Regel ist nur die Tabelle pgd_join_id_ldsg, diese wird im Vorsystem angelegt und hier werden Schreibrechte fürs Entladen benötigt, weil diese Tabelle eine Pseudonymisierungsfunktion von Personalnummern bietet, die DSGVO-konform nur im Vorsystem vorhanden ist.
--
--Sie können also z.B. einen User "biuser" in HISRM anlegen, mit folgenden Berechtigungen:
CREATE USER biuser WITH NOSUPERUSER PASSWORD 'xxx';
GRANT usage ON SCHEMA sva4 TO biuser; GRANT usage ON SCHEMA sva4 TO biuser;
grant create on schema sva4 to biuser; grant create on schema sva4 to biuser;

Loading…
Cancel
Save