diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 9fb7f0ee9..f728910e9 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -56,6 +56,7 @@ require_once('dbupdate_3.4/36530_bis_internationsalisierung_codextabelle_neuerun require_once('dbupdate_3.4/34543_ux_template.php'); require_once('dbupdate_3.4/17513_Entwicklungsteam.php'); require_once('dbupdate_3.4/28575_softwarebereitstellung.php'); +require_once('dbupdate_3.4/41150_oe-pfad_db_view.php'); // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; diff --git a/system/dbupdate_3.4/41150_oe-pfad_db_view.php b/system/dbupdate_3.4/41150_oe-pfad_db_view.php new file mode 100644 index 000000000..077033fbb --- /dev/null +++ b/system/dbupdate_3.4/41150_oe-pfad_db_view.php @@ -0,0 +1,37 @@ +db_query("SELECT * FROM information_schema.views WHERE table_catalog = '" . DB_NAME . "' AND table_schema = 'public' AND table_name = 'vw_oe_path'")) +{ + if($db->db_num_rows($result) == 0) + { + $qry = " + CREATE OR REPLACE VIEW public.vw_oe_path AS + WITH RECURSIVE vw_oe_path(oe_kurzbz, bezeichnung, oe_parent_kurzbz, organisationseinheittyp_kurzbz, oetyp_bezeichnung, depth, path) AS ( + SELECT + oe.oe_kurzbz, oe.bezeichnung, oe.oe_parent_kurzbz, oe.organisationseinheittyp_kurzbz, oetyp.bezeichnung AS oetyp_bezeichnung, 0, '/' || oetyp.bezeichnung || ' ' || oe.bezeichnung AS path + FROM + public.tbl_organisationseinheit oe + JOIN + public.tbl_organisationseinheittyp oetyp USING(organisationseinheittyp_kurzbz) + WHERE + oe.oe_parent_kurzbz IS NULL + UNION ALL + SELECT + oe.oe_kurzbz, oe.bezeichnung, oe.oe_parent_kurzbz, oe.organisationseinheittyp_kurzbz, oetyp.bezeichnung AS oetyp_bezeichnung, depth + 1, oet.path || '/' || oetyp.bezeichnung || ' ' || oe.bezeichnung + FROM + public.tbl_organisationseinheit oe, vw_oe_path oet + JOIN + public.tbl_organisationseinheittyp oetyp USING(organisationseinheittyp_kurzbz) + WHERE + oe.oe_parent_kurzbz = oet.oe_kurzbz + ) + SELECT * FROM vw_oe_path ORDER BY path, depth; + "; + + if (!$db->db_query($qry)) + echo 'public.vw_oe_path: ' . $db->db_last_error() . '
'; + else + echo 'public.vw_oe_path: erstellt
'; + } +}