From fd0eaaa366d0d53ac66297c806bd1271d6a0b29f Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 30 Sep 2019 14:11:04 +0200 Subject: [PATCH] Fixed: SQL subquery to only return one row The subquery was sometimes returning more rows causing error message. This is fixed now. --- application/views/lehre/lehrauftrag/acceptLehrauftragData.php | 3 ++- application/views/lehre/lehrauftrag/approveLehrauftragData.php | 3 ++- application/views/lehre/lehrauftrag/lehrauftragData.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php index 716dbfa98..8f8da50a1 100644 --- a/application/views/lehre/lehrauftrag/acceptLehrauftragData.php +++ b/application/views/lehre/lehrauftrag/acceptLehrauftragData.php @@ -123,7 +123,8 @@ FROM public.tbl_benutzer WHERE person_id = tmp_projektbetreuung.person_id - AND aktiv = TRUE) AS "mitarbeiter_uid", + ORDER BY aktiv DESC, updateaktivam DESC -- accept inactive as some person_ids have no active, but order them last + LIMIT 1) AS "mitarbeiter_uid", /* concatinated and aggregated gruppen */ (SELECT string_agg(concat(stg_oe_kurzbz, \'-\', semester, verband, gruppe, diff --git a/application/views/lehre/lehrauftrag/approveLehrauftragData.php b/application/views/lehre/lehrauftrag/approveLehrauftragData.php index 26cb25815..c799fc99e 100644 --- a/application/views/lehre/lehrauftrag/approveLehrauftragData.php +++ b/application/views/lehre/lehrauftrag/approveLehrauftragData.php @@ -122,7 +122,8 @@ FROM public.tbl_benutzer WHERE person_id = tmp_projektbetreuung.person_id - AND aktiv = TRUE) AS "mitarbeiter_uid", + ORDER BY aktiv DESC, updateaktivam DESC -- accept inactive as some person_ids have no active, but order them last + LIMIT 1) AS "mitarbeiter_uid", /* concatinated and aggregated gruppen */ (SELECT string_agg(concat(stg_oe_kurzbz, \'-\', semester, verband, gruppe, diff --git a/application/views/lehre/lehrauftrag/lehrauftragData.php b/application/views/lehre/lehrauftrag/lehrauftragData.php index 0945693f5..13f4fa251 100644 --- a/application/views/lehre/lehrauftrag/lehrauftragData.php +++ b/application/views/lehre/lehrauftrag/lehrauftragData.php @@ -122,7 +122,8 @@ FROM public.tbl_benutzer WHERE person_id = tmp_projektbetreuung.person_id - AND aktiv = TRUE) AS "mitarbeiter_uid", + ORDER BY aktiv DESC, updateaktivam DESC -- accept inactive as some person_ids have no active, but order them last + LIMIT 1) AS "mitarbeiter_uid", /* concatinated and aggregated gruppen */ (SELECT string_agg(concat(stg_oe_kurzbz, \'-\', semester, verband, gruppe,