x
1
-- File: trig_i_d_syst_hierarchies.eex.sql
2
-- Location: musebms/database/components/system/mscmp_syst_hierarchy/ms_syst/api_views/syst_hierarchies/trig_i_d_syst_hierarchies.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
17
RAISE EXCEPTION
18
USING
19
MESSAGE = 'You cannot delete a system defined Hierarchy using the API Views.',
20
DETAIL = ms_syst_priv.get_exception_details(
21
p_proc_schema => 'ms_appl'
22
,p_proc_name => 'trig_i_d_syst_hierarchies'
23
,p_exception_name => 'invalid_api_view_call'
24
,p_errcode => 'PM008'
25
,p_param_data => to_jsonb(old)
26
,p_context_data =>
27
jsonb_build_object(
28
'tg_op', tg_op
29
,'tg_when', tg_when
30
,'tg_schema', tg_table_schema
31
,'tg_table_name', tg_table_name)),
32
ERRCODE = 'PM008',
33
SCHEMA = tg_table_schema,
34
TABLE = tg_table_name;
35
36
END IF;
37
38
DELETE FROM ms_syst_data.syst_hierarchies WHERE id = old.id RETURNING * INTO old;
39
40
RETURN old;
41
42
END;