update kenn_antr_aggr set stg=(select K.keybund from k_astat_studienfach_land K where kenn_antr_aggr.stg=K.schluessel or kenn_antr_aggr.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_antr_aggr.stg=K.schluessel or kenn_antr_aggr.stg='0' || K.schluessel);
update kenn_lab_aggr_astat set stg=(select K.keybund from k_astat_studienfach_land K where kenn_lab_aggr_astat.stg=K.schluessel or kenn_lab_aggr_astat.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_lab_aggr_astat.stg=K.schluessel or kenn_lab_aggr_astat.stg='0' || K.schluessel);
insert into tmp_kenn_bland_hs (bland)
select astat from tmp_kenn_bland where apnr in (select K.bland from kenn_hochschulen K, hochschulinfo H where H.hs_nr=K.hs_nr);
update kenn_sos_lab set stg=(select K.keybund from k_astat_studienfach_land K where kenn_sos_lab.stg=K.schluessel or kenn_sos_lab.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_sos_lab.stg=K.schluessel or kenn_sos_lab.stg='0' || K.schluessel);
SELECT schluessel,
land,
null::char(10) as keybund,
max(nvl(gueltig_bis,30001)) as gueltig_bis
into temp tmp_stg
FROM k_astat_studienfach_land
where land=(select bland from tmp_kenn_bland_hs)
group by 1,2,3;
update kenn_sos_stg set stg=(select K.keybund from k_astat_studienfach_land K where kenn_sos_stg.stg=K.schluessel or kenn_sos_stg.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_sos_stg.stg=K.schluessel or kenn_sos_stg.stg='0' || K.schluessel);
update tmp_stg set keybund=(select distinct L.keybund
from k_astat_studienfach_land L
where L.schluessel=tmp_stg.schluessel
and L.land=tmp_stg.land
and (L.gueltig_bis=tmp_stg.gueltig_bis or (L.gueltig_bis is null and tmp_stg.gueltig_bis =30001))
);
update kenn_stg_aggr set stg=(select K.keybund from k_astat_studienfach_land K where kenn_stg_aggr.stg=K.schluessel or kenn_stg_aggr.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_stg_aggr.stg=K.schluessel or kenn_stg_aggr.stg='0' || K.schluessel);
update kenn_stg_aggr_astat set stg=(select K.keybund from k_astat_studienfach_land K where kenn_stg_aggr_astat.stg=K.schluessel or kenn_stg_aggr_astat.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_stg_aggr_astat.stg=K.schluessel or kenn_stg_aggr_astat.stg='0' || K.schluessel);
update kenn_antr_aggr set stg=(select K.keybund from tmp_stg K where (kenn_antr_aggr.stg=K.schluessel or kenn_antr_aggr.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_antr_aggr.stg=K.schluessel or kenn_antr_aggr.stg='0' || K.schluessel);
update kenn_lab_aggr_astat set stg=(select K.keybund from tmp_stg K where (kenn_lab_aggr_astat.stg=K.schluessel or kenn_lab_aggr_astat.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_lab_aggr_astat.stg=K.schluessel or kenn_lab_aggr_astat.stg='0' || K.schluessel);
update kenn_sos_lab set stg=(select K.keybund from tmp_stg K where (kenn_sos_lab.stg=K.schluessel or kenn_sos_lab.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_sos_lab.stg=K.schluessel or kenn_sos_lab.stg='0' || K.schluessel);
update kenn_sos_stg set stg=(select K.keybund from tmp_stg K where (kenn_sos_stg.stg=K.schluessel or kenn_sos_stg.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_sos_stg.stg=K.schluessel or kenn_sos_stg.stg='0' || K.schluessel);
update kenn_stg_aggr set stg=(select K.keybund from tmp_stg K where (kenn_stg_aggr.stg=K.schluessel or kenn_stg_aggr.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_stg_aggr.stg=K.schluessel or kenn_stg_aggr.stg='0' || K.schluessel);
update kenn_stg_aggr_astat set stg=(select K.keybund from tmp_stg K where (kenn_stg_aggr_astat.stg=K.schluessel or kenn_stg_aggr_astat.stg='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_stg_aggr_astat.stg=K.schluessel or kenn_stg_aggr_astat.stg='0' || K.schluessel);
update kenn_stg_int set astat=(select K.keybund from tmp_stg K where (kenn_stg_int.astat=K.schluessel or kenn_stg_int.astat='0' || K.schluessel))
where 1=(select count(*) from tmp_stg K where kenn_stg_int.astat=K.schluessel or kenn_stg_int.astat='0' || K.schluessel);
update kenn_antr_aggr set stg='0' || stg where length(trim(stg))=3;
update kenn_lab_aggr_astat set stg='0' || stg where length(trim(stg))=3;
update kenn_sos_lab set stg='0' || stg where length(trim(stg))=3;
update kenn_sos_stg set stg='0' || stg where length(trim(stg))=3;
update kenn_stg_aggr set stg='0' || stg where length(trim(stg))=3;
update kenn_stg_aggr_astat set stg='0' || stg where length(trim(stg))=3;
update kenn_stg_int set astat='0' || astat where length(trim(astat))=3;
update kenn_stg_int set stg=(select K.keybund from k_astat_studienfach_land K where kenn_stg_int.stg=K.schluessel or kenn_stg_int.stg='0' || K.schluessel)
where 1=(select count(*) from k_astat_studienfach_land K where kenn_stg_int.stg=K.schluessel or kenn_stg_int.stg='0' || K.schluessel);
update tmp_stg_aggr_astat set sb=(select A.parent from kenn_stg_astat A
where A.astat=tmp_stg_aggr_astat.stg);
@ -52,14 +99,13 @@ update tmp_stg_aggr_astat set fgr='U' where fgr is null;
@@ -52,14 +99,13 @@ update tmp_stg_aggr_astat set fgr='U' where fgr is null;
update kenn_stg_aggr_astat set fgr=(select min(T.fgr)
from tmp_stg_aggr_astat T
where T.stg=kenn_stg_aggr_astat.stg)
where fgr='U'
;
where T.stg=kenn_stg_aggr_astat.stg);
update kenn_lab_aggr_astat set fgr=(select min(T.fgr)