x
1
-- File: trig_i_d_syst_enums.eex.sql
2
-- Location: musebms/database/components/system/mscmp_syst_enums/ms_syst/api_views/syst_enums/trig_i_d_syst_enums.eex.sql
3
-- Project: Muse Systems Business Management System
4
--
5
-- Copyright © Lima Buttgereit Holdings LLC d/b/a Muse Systems
6
-- This file may include content copyrighted and licensed from third parties.
7
--
8
-- See the LICENSE file in the project root for license terms and conditions.
9
-- See the NOTICE file in the project root for copyright ownership information.
10
--
11
-- muse.information@musesystems.com :: https://muse.systems
12
13
BEGIN
14
15
IF old.syst_defined THEN
16
RAISE EXCEPTION
17
USING
18
MESSAGE = 'You cannot delete a system defined enumeration using the API Views.',
19
DETAIL = ms_syst_priv.get_exception_details(
20
p_proc_schema => 'ms_syst'
21
,p_proc_name => 'trig_i_d_syst_enums'
22
,p_exception_name => 'invalid_api_view_call'
23
,p_errcode => 'PM008'
24
,p_param_data => to_jsonb(old)
25
,p_context_data =>
26
jsonb_build_object(
27
'tg_op', tg_op
28
,'tg_when', tg_when
29
,'tg_schema', tg_table_schema
30
,'tg_table_name', tg_table_name)),
31
ERRCODE = 'PM008',
32
SCHEMA = tg_table_schema,
33
TABLE = tg_table_name;
34
END IF;
35
36
DELETE FROM ms_syst_data.syst_enums WHERE id = old.id RETURNING * INTO old;
37
38
RETURN old;
39
40
END;